[Lldb-commits] [lldb] r275165 - Fix a race on process exit

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 12 02:37:56 PDT 2016

Author: labath
Date: Tue Jul 12 04:37:55 2016
New Revision: 275165

URL: http://llvm.org/viewvc/llvm-project?rev=275165&view=rev
Fix a race on process exit

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.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D22209


Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=275165&r1=275164&r2=275165&view=diff
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Jul 12 04:37:55 2016
@@ -1462,14 +1462,6 @@ Process::SetExitStatus (int status, cons
-    // 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

More information about the lldb-commits mailing list