This is an archive of the discontinued LLVM Phabricator instance.

Fix race condition with -o "process launch" on linux
ClosedPublic

Authored by labath on Mar 5 2015, 5:03 AM.

Details

Summary

starting a debug session on linux with -o "process launch" lldb parameter was failing since
Target::Launch (in sychronous mode) is expecting to be able to receive public process events.
However, PlatformLinux did not set up event hijacking on process launch, which caused these
events to be processed elsewhere and left Target::Launch hanging. This patch enables event
interception in PlatformLinux (which was commented out).

Upon enabling event interception, I noticed an issue, which I traced back to the inconsistent
state of public run lock, which remained false even though public and private process states were
"stopped". I addressed this by making sure the run lock is "stopped" upon exit from
WaitForProcessToStop (which already had similar provisions for other return paths).

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 21269.Mar 5 2015, 5:03 AM
labath retitled this revision from to Fix race condition with -o "process launch" on linux.
labath updated this object.
labath edited the test plan for this revision. (Show Details)
labath added reviewers: jingham, clayborg, vharron.
labath added a subscriber: Unknown Object (MLST).
clayborg requested changes to this revision.Mar 5 2015, 9:40 AM
clayborg edited edge metadata.

If you hijack events, you must undo this by calling:

process_sp->RestoreProcessEvents();
source/Plugins/Platform/Linux/PlatformLinux.cpp
804 ↗(On Diff #21269)

If you hijack event above, you must unhijack by calling:

process_sp->RestoreProcessEvents();

So you can't remove this. It was a NOP before because it wasn't doing anything, but if you do hijack events, then you must unhijack.

This revision now requires changes to proceed.Mar 5 2015, 9:40 AM
labath added inline comments.Mar 5 2015, 11:10 AM
source/Plugins/Platform/Linux/PlatformLinux.cpp
804 ↗(On Diff #21269)

Ok, this sure does look dodgy when you look at it alone. :)
This hijacking will be restored later in Target::Launch (line 2689). I believe it is expected behavior for the DebugProcess function to exit with event hijacking on. For example, the base Platform::DebugProcess also hijacks events on line 1188, but does not restore it by itself.

clayborg accepted this revision.Mar 5 2015, 12:49 PM
clayborg edited edge metadata.

ok, looks good then.

This revision is now accepted and ready to land.Mar 5 2015, 12:49 PM
This revision was automatically updated to reflect the committed changes.