From owner-svn-src-head@freebsd.org Wed Oct 9 19:51:42 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9C1B512D954; Wed, 9 Oct 2019 19:51:42 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46pPxB3g4Lz3R8v; Wed, 9 Oct 2019 19:51:42 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 622A61D926; Wed, 9 Oct 2019 19:51:42 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x99JpgU1096334; Wed, 9 Oct 2019 19:51:42 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x99Jpf9Q096333; Wed, 9 Oct 2019 19:51:41 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201910091951.x99Jpf9Q096333@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 9 Oct 2019 19:51:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353363 - head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD X-SVN-Commit-Revision: 353363 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Oct 2019 19:51:42 -0000 Author: dim Date: Wed Oct 9 19:51:41 2019 New Revision: 353363 URL: https://svnweb.freebsd.org/changeset/base/353363 Log: Put in a band-aid fix for lldb 9 exiting with "Expected must be checked before access or destruction" when launching executables, while we sort this out with upstream. Reported by: jbeich PR: 241137 MFC after: 1 month X-MFC-With: r353358 Modified: head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h Modified: head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Wed Oct 9 18:46:56 2019 (r353362) +++ head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Wed Oct 9 19:51:41 2019 (r353363) @@ -708,7 +708,7 @@ ProcessMonitor::ProcessMonitor( const lldb_private::ProcessLaunchInfo & /* launch_info */, lldb_private::Status &error) : m_process(static_cast(process)), - m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) { + m_operation_thread(), m_monitor_thread(), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) { using namespace std::placeholders; std::unique_ptr args( @@ -735,20 +735,21 @@ ProcessMonitor::ProcessMonitor( } // Finally, start monitoring the child process for change in state. - m_monitor_thread = Host::StartMonitoringChildProcess( + auto monitor_thread = Host::StartMonitoringChildProcess( std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4), GetPID(), true); - if (!m_monitor_thread->IsJoinable()) { + if (!monitor_thread || !monitor_thread->IsJoinable()) { error.SetErrorToGenericError(); error.SetErrorString("Process launch failed."); return; } + m_monitor_thread = *monitor_thread; } ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid, lldb_private::Status &error) : m_process(static_cast(process)), - m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(pid), m_terminal_fd(-1), m_operation(0) { + m_operation_thread(), m_monitor_thread(), m_pid(pid), m_terminal_fd(-1), m_operation(0) { using namespace std::placeholders; sem_init(&m_operation_pending, 0, 0); @@ -773,14 +774,15 @@ ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process } // Finally, start monitoring the child process for change in state. - m_monitor_thread = Host::StartMonitoringChildProcess( + auto monitor_thread = Host::StartMonitoringChildProcess( std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4), GetPID(), true); - if (!m_monitor_thread->IsJoinable()) { + if (!monitor_thread || !monitor_thread->IsJoinable()) { error.SetErrorToGenericError(); error.SetErrorString("Process attach failed."); return; } + m_monitor_thread = *monitor_thread; } ProcessMonitor::~ProcessMonitor() { StopMonitor(); } @@ -789,13 +791,15 @@ ProcessMonitor::~ProcessMonitor() { StopMonitor(); } void ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Status &error) { static const char *g_thread_name = "freebsd.op"; - if (m_operation_thread->IsJoinable()) + if (m_operation_thread.IsJoinable()) return; - m_operation_thread = + auto operation_thread = ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args); - if (!m_operation_thread) - error = m_operation_thread.takeError(); + if (operation_thread) + m_operation_thread = *operation_thread; + else + error = operation_thread.takeError(); } void *ProcessMonitor::LaunchOpThread(void *arg) { @@ -957,14 +961,15 @@ void ProcessMonitor::StartAttachOpThread(AttachArgs *a lldb_private::Status &error) { static const char *g_thread_name = "freebsd.op"; - if (m_operation_thread->IsJoinable()) + if (m_operation_thread.IsJoinable()) return; - m_operation_thread = + auto operation_thread = ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args); - - if (!m_operation_thread) - error = m_operation_thread.takeError(); + if (operation_thread) + m_operation_thread = *operation_thread; + else + error = operation_thread.takeError(); } void *ProcessMonitor::AttachOpThread(void *arg) { @@ -1384,10 +1389,10 @@ bool ProcessMonitor::DupDescriptor(const FileSpec &fil } void ProcessMonitor::StopMonitoringChildProcess() { - if (m_monitor_thread->IsJoinable()) { - m_monitor_thread->Cancel(); - m_monitor_thread->Join(nullptr); - m_monitor_thread->Reset(); + if (m_monitor_thread.IsJoinable()) { + m_monitor_thread.Cancel(); + m_monitor_thread.Join(nullptr); + m_monitor_thread.Reset(); } } @@ -1422,10 +1427,10 @@ void ProcessMonitor::StopMonitor() { bool ProcessMonitor::WaitForInitialTIDStop(lldb::tid_t tid) { return true; } void ProcessMonitor::StopOpThread() { - if (!m_operation_thread->IsJoinable()) + if (!m_operation_thread.IsJoinable()) return; - m_operation_thread->Cancel(); - m_operation_thread->Join(nullptr); - m_operation_thread->Reset(); + m_operation_thread.Cancel(); + m_operation_thread.Join(nullptr); + m_operation_thread.Reset(); } Modified: head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h Wed Oct 9 18:46:56 2019 (r353362) +++ head/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h Wed Oct 9 19:51:41 2019 (r353363) @@ -183,8 +183,8 @@ class ProcessMonitor { (public) private: ProcessFreeBSD *m_process; - llvm::Expected m_operation_thread; - llvm::Expected m_monitor_thread; + lldb_private::HostThread m_operation_thread; + lldb_private::HostThread m_monitor_thread; lldb::pid_t m_pid; int m_terminal_fd;