[Lldb-commits] [lldb] r124038 - /lldb/trunk/source/Target/Process.cpp

Greg Clayton gclayton at apple.com
Sat Jan 22 09:43:17 PST 2011


Author: gclayton
Date: Sat Jan 22 11:43:17 2011
New Revision: 124038

URL: http://llvm.org/viewvc/llvm-project?rev=124038&view=rev
Log:
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. 

Modified:
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=124038&r1=124037&r2=124038&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Sat Jan 22 11:43:17 2011
@@ -2037,10 +2037,13 @@
             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 @@
         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;
         }
     }





More information about the lldb-commits mailing list