We were accessing the ModuleList in the target without locking it for tasks like
setting breakpoints. That's dangerous, since while we are setting a breakpoint,
the target might hit the dyld load notification, and start removing modules from
the list. This change adds a GetMutex accessor to the ModuleList class, and
uses it whenever we are accessing the target's ModuleList (as returned by GetImages().)
<rdar://problem/11552372>
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157668 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index 4c31c22..605747a 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -561,13 +561,14 @@
}
else
{
- ModuleList &images = m_target->GetImages();
+ ModuleList &target_images = m_target->GetImages();
+ Mutex::Locker modules_locker (target_images.GetMutex());
- for (uint32_t i = 0, e = images.GetSize();
+ for (uint32_t i = 0, e = target_images.GetSize();
i != e;
++i)
{
- lldb::ModuleSP image = images.GetModuleAtIndex(i);
+ lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
if (!image)
continue;
@@ -1339,14 +1340,16 @@
}
else
{
- ModuleList &images = m_target->GetImages();
+ ModuleList &target_images = m_target->GetImages();
+ Mutex::Locker modules_locker(target_images.GetMutex());
+
ClangNamespaceDecl null_namespace_decl;
- for (uint32_t i = 0, e = images.GetSize();
+ for (uint32_t i = 0, e = target_images.GetSize();
i != e;
++i)
{
- lldb::ModuleSP image = images.GetModuleAtIndex(i);
+ lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
if (!image)
continue;