This is an archive of the discontinued LLVM Phabricator instance.

Fix a race in ProcessGDBRemote::MonitorDebugServerProcess
ClosedPublic

Authored by labath on May 10 2016, 8:29 AM.

Details

Summary

MonitorDebugServerProcess went to a lot of effort to make sure its asynchronous invocation does
not cause any mischief, but it was still not race-free. Specifically, in a quick stop-restart
sequence (like the one in TestAddressBreakpoints) the copying of the process shared pointer via
target_sp->GetProcessSP() was racing with the resetting of the pointer in DeleteCurrentProcess,
as they were both accessing the same shared_ptr object.

To avoid this, I simply pass in a weak_ptr to the process when the callback is created. Locking
this pointer is race-free as they are two separate object even though they point to the same
process instance. This also removes the need for the complicated tap-dance around retrieving the
process pointer.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 56722.May 10 2016, 8:29 AM
labath retitled this revision from to Fix a race in ProcessGDBRemote::MonitorDebugServerProcess.
labath updated this object.
labath added a reviewer: clayborg.
labath added subscribers: lldb-commits, tberghammer.
clayborg accepted this revision.May 10 2016, 10:10 AM
clayborg edited edge metadata.

Looks good.

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