This is an archive of the discontinued LLVM Phabricator instance.

Don't resume when creating new threads if there is a pending thread stop.
AbandonedPublic

Authored by chaoren on Apr 8 2015, 2:32 PM.

Details

Summary

In the rare event that a thread is created immediately before a breakpoint hit,
the newly created thread and the main thread would be incorrectly resumed
by the creation process.

Diff Detail

Event Timeline

chaoren updated this revision to Diff 23443.Apr 8 2015, 2:32 PM
chaoren retitled this revision from to Don't resume newly created threads if there is a pending thread stop..
chaoren updated this object.
chaoren edited the test plan for this revision. (Show Details)
chaoren added a reviewer: clayborg.
chaoren added a subscriber: Unknown Object (MLST).
chaoren updated this revision to Diff 23458.Apr 8 2015, 5:23 PM

Need to prevent the main thread from resuming as well.

chaoren retitled this revision from Don't resume newly created threads if there is a pending thread stop. to Don't resume when creating new threads if there is a pending thread stop..Apr 8 2015, 5:24 PM
chaoren updated this object.
chaoren added reviewers: vharron, ovyalov.
chaoren added inline comments.Apr 8 2015, 5:27 PM
source/Plugins/Process/Linux/NativeProcessLinux.cpp
2487

I don't think this gets called at all. Is the duplicate code here necessary?

chaoren updated this revision to Diff 23459.Apr 8 2015, 6:01 PM

Remove xfail caused by this.

ovyalov requested changes to this revision.Apr 8 2015, 8:30 PM
ovyalov edited edge metadata.
ovyalov added inline comments.
source/Plugins/Process/Linux/NativeProcessLinux.cpp
2135–2151

It looks to me there might be a race - if you'll be calling this method when TSC inside of ProcessEvent call between RequestStopOnAllRunningThreads() and coordinator.SetPendingNotification() a thread might be mistakenly resumed. So, you may to synchronize IsPendingThreadStop with ProcessEvent().

Can we make RequestThreadResume take additional boolean argument to check for pending stopped state - so, effectively move this conditional logic into EventRequestResume?

source/Plugins/Process/Linux/ThreadStateCoordinator.h
152

This method should be synchronized - GetPendingThreadStopNotification() is used now only within TSC thread and that's why doesn't need synchronization. But if you're going to call it from another thread GetPendingThreadStopNotification should be protected by mutex.

This revision now requires changes to proceed.Apr 8 2015, 8:30 PM
chaoren abandoned this revision.Apr 10 2015, 11:12 AM

I think I'm mistaken about the actual cause of the race condition.