summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2011-10-31 23:47:10 +0000
committerJim Ingham <jingham@apple.com>2011-10-31 23:47:10 +0000
commit549f737453d1de96c61df8146edcff48b9b20877 (patch)
treec8d20d56dd12e43d94fd64f9a45a380488af92f7 /lldb/source
parente9839c045fd55016820c8b129adbd5ae3a6e3db3 (diff)
downloadbcm5719-llvm-549f737453d1de96c61df8146edcff48b9b20877.tar.gz
bcm5719-llvm-549f737453d1de96c61df8146edcff48b9b20877.zip
We can't have the global vector of modules be a static object, or it might get destroyed
before all the modules, which will then crash when the next modules tries to take itself off it. llvm-svn: 143402
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Core/Module.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 3f8a7635144..64677e0873d 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -28,8 +28,17 @@ typedef std::vector<Module *> ModuleCollection;
static ModuleCollection &
GetModuleCollection()
{
- static ModuleCollection g_module_collection;
- return g_module_collection;
+ // This module collection needs to live past any module, so we could either make it a
+ // shared pointer in each module or just leak is. Since it is only an empty vector by
+ // the time all the modules have gone away, we just leak it for now. If we decide this
+ // is a big problem we can introduce a Finalize method that will tear everything down in
+ // a predictable order.
+
+ static ModuleCollection *g_module_collection = NULL;
+ if (g_module_collection == NULL)
+ g_module_collection = new ModuleCollection();
+
+ return *g_module_collection;
}
Mutex &
OpenPOWER on IntegriCloud