[Lldb-commits] [lldb] c72c0b2 - Fix race condition during iteration through modules (#139283) (#139862)

via lldb-commits lldb-commits at lists.llvm.org
Fri May 16 09:09:54 PDT 2025


Author: nd
Date: 2025-05-16T09:09:50-07:00
New Revision: c72c0b298c13ebc4d374e84b8ea20f8ca4f5ace2

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

LOG: Fix race condition during iteration through modules (#139283) (#139862)

Use the locking iterator to ensure module don't change during iteration.

Added: 
    

Modified: 
    lldb/source/Target/Target.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 7f61f8689fb95..9660fc97970b0 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1511,8 +1511,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t watch_id,
 
 ModuleSP Target::GetExecutableModule() {
   // search for the first executable in the module list
-  for (size_t i = 0; i < m_images.GetSize(); ++i) {
-    ModuleSP module_sp = m_images.GetModuleAtIndex(i);
+  for (ModuleSP module_sp : m_images.Modules()) {
     lldb_private::ObjectFile *obj = module_sp->GetObjectFile();
     if (obj == nullptr)
       continue;


        


More information about the lldb-commits mailing list