[Lldb-commits] [lldb] d75dc9a - [lldb] Fix ThreadList::Update not locking the rhs's mutex

Augusto Noronha via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 4 16:12:07 PDT 2023


Author: Augusto Noronha
Date: 2023-08-04T16:01:20-07:00
New Revision: d75dc9a8a86c4f69408dcab3a21416729d14652e

URL: https://github.com/llvm/llvm-project/commit/d75dc9a8a86c4f69408dcab3a21416729d14652e
DIFF: https://github.com/llvm/llvm-project/commit/d75dc9a8a86c4f69408dcab3a21416729d14652e.diff

LOG: [lldb] Fix ThreadList::Update not locking the rhs's mutex

ThreadList::Update is being caught by thread sanitizer. There's even a
comment on the function that both mutexes should be lock (even though
only the "this" mutex was actually being locked). Fix this by locking
both mutexes.

Differential Revision: https://reviews.llvm.org/D157153

Added: 
    

Modified: 
    lldb/source/Target/ThreadList.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp
index 006c8648be524a..c5c3f667c90471 100644
--- a/lldb/source/Target/ThreadList.cpp
+++ b/lldb/source/Target/ThreadList.cpp
@@ -736,7 +736,7 @@ void ThreadList::Update(ThreadList &rhs) {
   if (this != &rhs) {
     // Lock both mutexes to make sure neither side changes anyone on us while
     // the assignment occurs
-    std::lock_guard<std::recursive_mutex> guard(GetMutex());
+    std::scoped_lock guard(GetMutex(), rhs.GetMutex());
 
     m_process = rhs.m_process;
     m_stop_id = rhs.m_stop_id;


        


More information about the lldb-commits mailing list