[Lldb-commits] [PATCH] Fix deadlock in operation thread in NativeProcessLinux

Tamas Berghammer tberghammer at google.com
Tue Mar 3 04:05:44 PST 2015


Hi ovyalov,

Fix deadlock in operation thread in NativeProcessLinux

The deadlock occurred when the Attach or the Launch operation failed for any reason.

http://reviews.llvm.org/D8030

Files:
  source/Plugins/Process/Linux/NativeProcessLinux.cpp

Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -3564,9 +3564,9 @@
 void
 NativeProcessLinux::StopMonitor()
 {
-    StopOpThread();
     StopMonitoringChildProcess();
     StopCoordinatorThread ();
+    StopOpThread();
     sem_destroy(&m_operation_pending);
     sem_destroy(&m_operation_done);
 
@@ -3583,7 +3583,16 @@
     if (!m_operation_thread.IsJoinable())
         return;
 
-    DoOperation(nullptr); // nullptr as operation ask the operation thread to exit
+    // If the state is invalid, attaching or launching then the operation thread will exit on there
+    // own. We don't have to send explicit stop request.
+    lldb::StateType state = GetState();
+    if (state != StateType::eStateInvalid &&
+        state != StateType::eStateAttaching &&
+        state != StateType::eStateLaunching)
+    {
+        DoOperation(nullptr); // nullptr as operation ask the operation thread to exit
+    }
+
     m_operation_thread.Join(nullptr);
 }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8030.21094.patch
Type: text/x-patch
Size: 1149 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150303/ced12657/attachment.bin>


More information about the lldb-commits mailing list