LLDB: Fixed two race conditions when stopping private state thread
authorMarianne Mailhot-Sarrasin <marianne.mailhot.sarrasin@gmail.com>
Tue, 19 Apr 2016 13:21:46 +0000 (13:21 +0000)
committerMarianne Mailhot-Sarrasin <marianne.mailhot.sarrasin@gmail.com>
Tue, 19 Apr 2016 13:21:46 +0000 (13:21 +0000)
commit0c6d7c0a2c7e227338fe3fd7d397f210dd0b6b20
tree02f9e1acfb32426ff389543398927e87c4dafe13
parent998cffa6b921a469e892269e0961a8eec69bf3fe
LLDB: Fixed two race conditions when stopping private state thread

When stopping the private state thread, there was a race condition between the time the thread exits (resetting the HostThread object) and the time a Join was attempted, especially in the case of a timeout.

The previous workaround of copying the HostThread object is not enough, since on a Reset the internal thread stuff gets nulled out regardless of which HostThread object actually has Reset called on it, resulting in an attempt to dereference a null pointer on the subsequent call to Join from the copy as well.

Additionally, there was a race between the detach (called when stopping the process) and the stop itself, causing the stop to time out because it was waiting for the private state thread to see the stop state, but it had exited immediately after entering the detached state.

Patch by cameron314

Differential Revision: http://reviews.llvm.org/D19122

llvm-svn: 266733
lldb/include/lldb/Target/Process.h
lldb/source/Target/Process.cpp