diff options
author | Greg Clayton <gclayton@apple.com> | 2011-01-22 17:43:17 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-01-22 17:43:17 +0000 |
commit | 7ecb3a040bfdae9d51388b90417b8f9a0ee19558 (patch) | |
tree | 7306d406ccd19a2ff0a30bbf288b499fd2909bff /lldb/source/Target/Process.cpp | |
parent | 67f9e61127ebfaf4925b95597dd6d7d35fcb75c0 (diff) | |
download | bcm5719-llvm-7ecb3a040bfdae9d51388b90417b8f9a0ee19558.tar.gz bcm5719-llvm-7ecb3a040bfdae9d51388b90417b8f9a0ee19558.zip |
Avoid the race condition Stephen Wilson was worried about in revision 123465 by making a local copy. We need to be able to have the private state thread let the lldb_private::Process class that it has exited, otherwise we end up with a timeout when the process destructor or DoDestroy is called where the private state thread has already exited and then StopPrivateStateThread() will wait for the thread which has already existed to respond to it.
llvm-svn: 124038
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index dab34765ef5..90ea0b6cb18 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2037,10 +2037,13 @@ Process::ControlPrivateStateThread (uint32_t signal) signal == eBroadcastInternalStateControlResume); if (log) - log->Printf ("Process::%s ( ) - signal: %d", __FUNCTION__, signal); + log->Printf ("Process::%s (signal = %d)", __FUNCTION__, signal); - // Signal the private state thread - if (m_private_state_thread != LLDB_INVALID_HOST_THREAD) + // Signal the private state thread. First we should copy this is case the + // thread starts exiting since the private state thread will NULL this out + // when it exits + const lldb::thread_t private_state_thread = m_private_state_thread; + if (private_state_thread != LLDB_INVALID_HOST_THREAD) { TimeValue timeout_time; bool timed_out; @@ -2055,10 +2058,10 @@ Process::ControlPrivateStateThread (uint32_t signal) if (signal == eBroadcastInternalStateControlStop) { if (timed_out) - Host::ThreadCancel (m_private_state_thread, NULL); + Host::ThreadCancel (private_state_thread, NULL); thread_result_t result = NULL; - Host::ThreadJoin (m_private_state_thread, &result, NULL); + Host::ThreadJoin (private_state_thread, &result, NULL); m_private_state_thread = LLDB_INVALID_HOST_THREAD; } } |