This revision was automatically updated to reflect the committed changes.
Closed by commit rL266733: LLDB: Fixed two race conditions when stopping 
private state thread (authored by mamai).

Changed prior to commit:
  http://reviews.llvm.org/D19122?vs=54098&id=54185#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19122

Files:
  lldb/trunk/include/lldb/Target/Process.h
  lldb/trunk/source/Target/Process.cpp

Index: lldb/trunk/source/Target/Process.cpp
===================================================================
--- lldb/trunk/source/Target/Process.cpp
+++ lldb/trunk/source/Target/Process.cpp
@@ -4112,11 +4112,8 @@
     if (log)
         log->Printf ("Process::%s (signal = %d)", __FUNCTION__, signal);
 
-    // 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
-    HostThread private_state_thread(m_private_state_thread);
-    if (private_state_thread.IsJoinable())
+    // Signal the private state thread
+    if (PrivateStateThreadIsValid())
     {
         TimeValue timeout_time;
         bool timed_out;
@@ -4134,7 +4131,7 @@
         {
             if (timed_out)
             {
-                Error error = private_state_thread.Cancel();
+                Error error = m_private_state_thread.Cancel();
                 if (log)
                     log->Printf ("Timed out responding to the control event, 
cancel got error: \"%s\".", error.AsCString());
             }
@@ -4145,7 +4142,7 @@
             }
 
             thread_result_t result = NULL;
-            private_state_thread.Join(&result);
+            m_private_state_thread.Join(&result);
             m_private_state_thread.Reset();
         }
     }
@@ -4449,7 +4446,6 @@
     if (!is_secondary_thread)
         m_public_run_lock.SetStopped();
     m_private_state_control_wait.SetValue (true, eBroadcastAlways);
-    m_private_state_thread.Reset();
     return NULL;
 }
 
Index: lldb/trunk/include/lldb/Target/Process.h
===================================================================
--- lldb/trunk/include/lldb/Target/Process.h
+++ lldb/trunk/include/lldb/Target/Process.h
@@ -3310,7 +3310,10 @@
     bool
     PrivateStateThreadIsValid () const
     {
-        return m_private_state_thread.IsJoinable();
+        lldb::StateType state = m_private_state.GetValue();
+        return state != lldb::eStateDetached &&
+               state != lldb::eStateExited &&
+               m_private_state_thread.IsJoinable();
     }
     
     void


Index: lldb/trunk/source/Target/Process.cpp
===================================================================
--- lldb/trunk/source/Target/Process.cpp
+++ lldb/trunk/source/Target/Process.cpp
@@ -4112,11 +4112,8 @@
     if (log)
         log->Printf ("Process::%s (signal = %d)", __FUNCTION__, signal);
 
-    // 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
-    HostThread private_state_thread(m_private_state_thread);
-    if (private_state_thread.IsJoinable())
+    // Signal the private state thread
+    if (PrivateStateThreadIsValid())
     {
         TimeValue timeout_time;
         bool timed_out;
@@ -4134,7 +4131,7 @@
         {
             if (timed_out)
             {
-                Error error = private_state_thread.Cancel();
+                Error error = m_private_state_thread.Cancel();
                 if (log)
                     log->Printf ("Timed out responding to the control event, cancel got error: \"%s\".", error.AsCString());
             }
@@ -4145,7 +4142,7 @@
             }
 
             thread_result_t result = NULL;
-            private_state_thread.Join(&result);
+            m_private_state_thread.Join(&result);
             m_private_state_thread.Reset();
         }
     }
@@ -4449,7 +4446,6 @@
     if (!is_secondary_thread)
         m_public_run_lock.SetStopped();
     m_private_state_control_wait.SetValue (true, eBroadcastAlways);
-    m_private_state_thread.Reset();
     return NULL;
 }
 
Index: lldb/trunk/include/lldb/Target/Process.h
===================================================================
--- lldb/trunk/include/lldb/Target/Process.h
+++ lldb/trunk/include/lldb/Target/Process.h
@@ -3310,7 +3310,10 @@
     bool
     PrivateStateThreadIsValid () const
     {
-        return m_private_state_thread.IsJoinable();
+        lldb::StateType state = m_private_state.GetValue();
+        return state != lldb::eStateDetached &&
+               state != lldb::eStateExited &&
+               m_private_state_thread.IsJoinable();
     }
     
     void
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to