This is an archive of the discontinued LLVM Phabricator instance.

Fix rare failure in TestProcessIO
ClosedPublic

Authored by labath on Sep 2 2015, 9:20 AM.

Details

Summary

There was a race condition in Process class, where we would not wait for process stdout to
propagate fully before we would shut down the connection (repro case: slow down the stdio thread
by placing a sleep right at the end of the while loop in Communication::ReadThread). The Process
class already tried to solve this problem by synchronizing with the read thread in
Process::ShouldBroadcastEvent, but unfortunately the connection got closed before that in
Process::SetExitStatus. I solve this issue by delaying the connection shutdown until we get a
chance to process the event and synchronize. Alternatively, I could have moved the
synchronization point to an earlier point in SetExitStatus, but it seems safer to delay the
shutdown until other things get a chance to notice the process has exited.

Diff Detail

Event Timeline

labath updated this revision to Diff 33815.Sep 2 2015, 9:20 AM
labath retitled this revision from to Fix rare failure in TestProcessIO.
labath updated this object.
labath added reviewers: clayborg, ovyalov.
labath added a subscriber: lldb-commits.
clayborg accepted this revision.Sep 2 2015, 11:06 AM
clayborg edited edge metadata.

Looks fine.

This revision is now accepted and ready to land.Sep 2 2015, 11:06 AM
This revision was automatically updated to reflect the committed changes.