From 194357c5092b34ca2487da76ef828a82b4a4da34 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 12 May 2016 11:10:01 +0000 Subject: Fix a race in ProcessGDBRemote::MonitorDebugServerProcess Summary: MonitorDebugServerProcess went to a lot of effort to make sure its asynchronous invocation does not cause any mischief, but it was still not race-free. Specifically, in a quick stop-restart sequence (like the one in TestAddressBreakpoints) the copying of the process shared pointer via target_sp->GetProcessSP() was racing with the resetting of the pointer in DeleteCurrentProcess, as they were both accessing the same shared_ptr object. To avoid this, I simply pass in a weak_ptr to the process when the callback is created. Locking this pointer is race-free as they are two separate object even though they point to the same process instance. This also removes the need for the complicated tap-dance around retrieving the process pointer. Reviewers: clayborg Subscribers: tberghammer, lldb-commits Differential Revision: http://reviews.llvm.org/D20107 llvm-svn: 269281 --- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h') diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 54d77a5d53a..815435c0f74 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -405,7 +405,8 @@ protected: AsyncThread (void *arg); static bool - MonitorDebugserverProcess(ProcessGDBRemote *process, lldb::pid_t pid, bool exited, int signo, int exit_status); + MonitorDebugserverProcess(std::weak_ptr process_wp, lldb::pid_t pid, bool exited, int signo, + int exit_status); lldb::StateType SetThreadStopInfo (StringExtractor& stop_packet); -- cgit v1.2.3