[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 14:07:04 PDT 2016
cameron314 added inline comments.
Comment at: source/Target/Process.cpp:4116
@@ -4120,1 +4115,3 @@
+ // Signal the private state thread
+ if (m_private_state_thread.IsJoinable())
> If you are going to do IsJoinable(), Cancel(), and Join() then this is still racy in that someone else could do the same thing on another thread. So this code should probably take a mutex to protect:
> Mutex::Locker locker(m_private_state_thread.GetMutex());
> if (m_private_state_thread.IsJoinable())
> This would need to live in HostNativeThreadBase because HostThread contains a shared pointer to a HostNativeThreadBase and HostThread can be copied.
I removed the call to `Reset` from the other thread (line 4452 below). It didn't make sense for a thread to reset its own `HostThread` since it's not its own owner, the Process is.
So now only the `Process` is allowed to control the `HostThread` it owns, and there's no races and thus no need for a mutex.
More information about the lldb-commits