summaryrefslogtreecommitdiff
path: root/lldb/source/Target/Target.cpp
diff options
context:
space:
mode:
authornd <dmitry.neverov@gmail.com>2025-05-16 18:09:50 +0200
committerGitHub <noreply@github.com>2025-05-16 09:09:50 -0700
commitc72c0b298c13ebc4d374e84b8ea20f8ca4f5ace2 (patch)
tree9c726df675ac23372ea7df154e256d04fe4c542c /lldb/source/Target/Target.cpp
parent2f5a24d0c555832ec6e5747cc7bad814ed97cbdc (diff)
Fix race condition during iteration through modules (#139283) (#139862)
Use the locking iterator to ensure module don't change during iteration.
Diffstat (limited to 'lldb/source/Target/Target.cpp')
-rw-r--r--lldb/source/Target/Target.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 7f61f8689fb9..9660fc97970b 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;