diff options
author | Greg Clayton <gclayton@apple.com> | 2016-02-26 23:20:08 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2016-02-26 23:20:08 +0000 |
commit | cc2e27f098b0515a7f4d2478c7bebe30169a49d6 (patch) | |
tree | eb6d2b94c71d12387f3f45afc9a863947a7cb6d9 /lldb/source/Target/Process.cpp | |
parent | 0c95decaaa8d82e8b85e46b81215b0131dfa6f8a (diff) | |
download | bcm5719-llvm-cc2e27f098b0515a7f4d2478c7bebe30169a49d6.tar.gz bcm5719-llvm-cc2e27f098b0515a7f4d2478c7bebe30169a49d6.zip |
Make LLDB safer to use with respect to the global destructor chain.
llvm-svn: 262090
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 29a16b599bc..8340c4055c1 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -833,13 +833,14 @@ Process::~Process() const ProcessPropertiesSP & Process::GetGlobalProperties() { - static ProcessPropertiesSP g_settings_sp; + // NOTE: intentional leak so we don't crash if global destructor chain gets + // called as other threads still use the result of this function + static ProcessPropertiesSP *g_settings_sp_ptr = nullptr; static std::once_flag g_once_flag; std::call_once(g_once_flag, []() { - if (!g_settings_sp) - g_settings_sp.reset (new ProcessProperties (NULL)); + g_settings_sp_ptr = new ProcessPropertiesSP(new ProcessProperties (NULL)); }); - return g_settings_sp; + return *g_settings_sp_ptr; } void |