[Lldb-commits] [PATCH] D22209: Fix a race on process exit

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 11 03:17:51 PDT 2016


labath created this revision.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.

Process::SetExitStatus was popping the process io handler and resetting m_process_input_reader
shared pointer, which is not a safe thing to do as the function is called asynchronously and
other threads may be accessing the member variable. (E.g. if the process terminates really
quickly, the private state thread might only be in the process of pushing the handler on the
stack. Sometimes, this leads to deadlock, as the shared pointer's state gets corrupted by the
concurrent access.

Since the IOHandler will be popped anyway in Process:HandleProcessStateChangedEvent when the
exited event gets processed, doing the same in SetExitStatus seems to be unnecessary.

http://reviews.llvm.org/D22209

Files:
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===================================================================
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -1462,14 +1462,6 @@
     else
         m_exit_string.clear();
 
-    // When we exit, we don't need the input reader anymore
-    if (m_process_input_reader)
-    {
-        m_process_input_reader->SetIsDone(true);
-        m_process_input_reader->Cancel();
-        m_process_input_reader.reset();
-    }
-
     // Clear the last natural stop ID since it has a strong
     // reference to this process
     m_mod_id.SetStopEventForLastNaturalStopID(EventSP());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22209.63481.patch
Type: text/x-patch
Size: 626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160711/7b1ac8c8/attachment.bin>


More information about the lldb-commits mailing list