[Lldb-commits] [PATCH] D19122: LLDB: Fixed race condition on timeout when stopping private state thread
Cameron via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 14 09:32:16 PDT 2016
cameron314 created this revision.
cameron314 added reviewers: clayborg, zturner, jingham.
cameron314 added subscribers: mamai, lldb-commits.
cameron314 set the repository for this revision to rL LLVM.
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.
In our environment (custom target), we were hitting this every time we stopped debugging.
@@ -4112,11 +4112,8 @@
log->Printf ("Process::%s (signal = %d)", __FUNCTION__, signal);
- // Signal the private state thread. First we should copy this is case the
- // thread starts exiting since the private state thread will NULL this out
- // when it exits
- HostThread private_state_thread(m_private_state_thread);
- if (private_state_thread.IsJoinable())
+ // Signal the private state thread
+ if (m_private_state_thread.IsJoinable())
@@ -4134,7 +4131,7 @@
- Error error = private_state_thread.Cancel();
+ Error error = m_private_state_thread.Cancel();
log->Printf ("Timed out responding to the control event, cancel got error: \"%s\".", error.AsCString());
@@ -4145,7 +4142,7 @@
thread_result_t result = NULL;
@@ -4449,7 +4446,6 @@
m_private_state_control_wait.SetValue (true, eBroadcastAlways);
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1550 bytes
Desc: not available
More information about the lldb-commits