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

Augusto Noronha via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 4 16:01:21 PDT 2023


augusto2112 created this revision.
augusto2112 added reviewers: jingham, JDevlieghere.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157153

Files:
  lldb/source/Target/ThreadList.cpp


Index: lldb/source/Target/ThreadList.cpp
===================================================================
--- lldb/source/Target/ThreadList.cpp
+++ lldb/source/Target/ThreadList.cpp
@@ -736,7 +736,7 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157153.547387.patch
Type: text/x-patch
Size: 522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230804/51e767b6/attachment-0001.bin>


More information about the lldb-commits mailing list