This is an archive of the discontinued LLVM Phabricator instance.

Log: Fix race in accessing the stream variable
ClosedPublic

Authored by labath on Feb 20 2017, 7:23 AM.

Details

Summary

The code was attempting to copy the shared pointer member in order to
guarantee atomicity, but this is not enough. Instead, protect the
pointer with a proper read-write mutex.

This bug was present here for a long time, but my recent refactors must
have altered the timings slightly, such that now this fails fairly often
when running the tests: the test runner runs the "log disable" command
just as the thread monitoring the lldb-server child is about to report
that the server has exited.

I add a test case for this. It's not possible to reproduce the race
deterministically in normal circumstances, but I have verified that
before the fix, the test failed when run under tsan, and was running
fine afterwards.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Feb 20 2017, 7:23 AM
clayborg accepted this revision.Feb 20 2017, 9:55 AM
This revision is now accepted and ready to land.Feb 20 2017, 9:55 AM
This revision was automatically updated to reflect the committed changes.