summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/Module.h2
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp6
-rw-r--r--lldb/source/Core/Module.cpp13
3 files changed, 14 insertions, 7 deletions
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index aabdd4ac313..bf8ed401c74 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -64,7 +64,7 @@ public:
static Module *
GetAllocatedModuleAtIndex (size_t idx);
- static Mutex &
+ static Mutex *
GetAllocationModuleCollectionMutex();
//------------------------------------------------------------------
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 29f5b9f7796..8b0fd17d159 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1632,7 +1632,7 @@ FindModulesByName (Target *target,
if (check_global_list && num_matches == 0)
{
// Check the global list
- Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex().GetMutex());
+ Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex());
const uint32_t num_modules = Module::GetNumberAllocatedModules();
ModuleSP module_sp;
for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx)
@@ -2051,7 +2051,7 @@ public:
else
{
// Check the global list
- Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex().GetMutex());
+ Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex());
result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr);
}
@@ -2785,7 +2785,7 @@ public:
if (use_global_module_list)
{
- locker.Reset (Module::GetAllocationModuleCollectionMutex().GetMutex());
+ locker.Reset (Module::GetAllocationModuleCollectionMutex()->GetMutex());
num_modules = Module::GetNumberAllocatedModules();
}
else
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index ea16376aa34..62b25c50015 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -43,11 +43,18 @@ GetModuleCollection()
return *g_module_collection;
}
-Mutex &
+Mutex *
Module::GetAllocationModuleCollectionMutex()
{
- static Mutex g_module_collection_mutex(Mutex::eMutexTypeRecursive);
- return g_module_collection_mutex;
+ // NOTE: The mutex below must be leaked since the global module list in
+ // the ModuleList class will get torn at some point, and we can't know
+ // if it will tear itself down before the "g_module_collection_mutex" below
+ // will. So we leak a Mutex object below to safeguard against that
+
+ static Mutex *g_module_collection_mutex = NULL;
+ if (g_module_collection_mutex == NULL)
+ g_module_collection_mutex = new Mutex (Mutex::eMutexTypeRecursive); // NOTE: known leak
+ return g_module_collection_mutex;
}
size_t
OpenPOWER on IntegriCloud