[Lldb-commits] [PATCH] D19122: LLDB: Fixed race condition on timeout when stopping private state thread

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 14 11:01:13 PDT 2016

clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

If you use the instance variable directly, we will need a mutex inside the HostNativeThreadBase class to protect against multi-threaded access. I believe the reason it was being copied before was in case the Reset was called on another thread. So we might want a mutex in HostNativeThreadBase that gets exposed via HostThread. See inlined 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.



More information about the lldb-commits mailing list