Page MenuHomePhabricator

Fix race condition in process resume
ClosedPublic

Authored by labath on Oct 26 2015, 10:08 AM.

Details

Summary

Gdb-remote's async thread sent out the eBroadcastBitRunPacketSent message *before* actually
sending out the continue packet. Since it's this message the actually triggers the public state
transition, it could happen (and it did happen in TestAttachResume, which does an "process
interrupt" right after a continue) that we attempt to stop the inferior before it was actually
started (which obviously did not end well). This fixes the problem by moving the broadcast after
the packet was actually sent.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 38429.Oct 26 2015, 10:08 AM
labath retitled this revision from to Fix race condition in process resume.
labath updated this object.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.
clayborg accepted this revision.Oct 26 2015, 10:13 AM
clayborg edited edge metadata.

Looks good as long as we always want to send the broadcast even if the continue packet fails to send.

source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
1074–1079 ↗(On Diff #38429)

Do we want this to happen even if we fail to send the packet? Should this code be in the else clause above?

This revision is now accepted and ready to land.Oct 26 2015, 10:13 AM
labath added inline comments.Oct 26 2015, 10:21 AM
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
1074–1079 ↗(On Diff #38429)

It was always sent before this change, so I'd probably keep it that way. If the sending fails, we'll have to tear down the whole process anyway.

This revision was automatically updated to reflect the committed changes.