Skip to content

Commit 8c0c768

Browse files
ndJDevlieghere
authored andcommitted
Fix race condition during iteration through modules (llvm#139283) (llvm#139862)
Use the locking iterator to ensure module don't change during iteration. (cherry picked from commit c72c0b2)
1 parent 45781f1 commit 8c0c768

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lldb/source/Target/Target.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,8 +1452,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t watch_id,
14521452

14531453
ModuleSP Target::GetExecutableModule() {
14541454
// search for the first executable in the module list
1455-
for (size_t i = 0; i < m_images.GetSize(); ++i) {
1456-
ModuleSP module_sp = m_images.GetModuleAtIndex(i);
1455+
for (ModuleSP module_sp : m_images.Modules()) {
14571456
lldb_private::ObjectFile *obj = module_sp->GetObjectFile();
14581457
if (obj == nullptr)
14591458
continue;

0 commit comments

Comments
 (0)