From dc15f1d7b84aa24dc3666f566bff95ebd27cfbbd Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 12 Jul 2016 09:37:55 +0000 Subject: [PATCH] Fix a race on process exit Summary: 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 llvm-svn: 275165 --- lldb/source/Target/Process.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 1f092f9c7146..3d1065450e81 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1462,14 +1462,6 @@ Process::SetExitStatus (int status, const char *cstr) 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());