This is an archive of the discontinued LLVM Phabricator instance.

Fix a race on process exit
ClosedPublic

Authored by labath on Jul 11 2016, 3:17 AM.

Details

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.

Diff Detail

Event Timeline

labath updated this revision to Diff 63481.Jul 11 2016, 3:17 AM
labath retitled this revision from to Fix a race on process exit.
labath updated this object.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.
clayborg accepted this revision.Jul 11 2016, 10:01 AM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Jul 11 2016, 10:01 AM
This revision was automatically updated to reflect the committed changes.