[Lldb-commits] [lldb] r262090 - Make LLDB safer to use with respect to the global destructor chain.
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 26 15:20:08 PST 2016
Author: gclayton
Date: Fri Feb 26 17:20:08 2016
New Revision: 262090
URL: http://llvm.org/viewvc/llvm-project?rev=262090&view=rev
Log:
Make LLDB safer to use with respect to the global destructor chain.
Modified:
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Target/Thread.cpp
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=262090&r1=262089&r2=262090&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Feb 26 17:20:08 2016
@@ -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
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=262090&r1=262089&r2=262090&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Feb 26 17:20:08 2016
@@ -2778,13 +2778,14 @@ Target::RunStopHooks ()
const TargetPropertiesSP &
Target::GetGlobalProperties()
{
- static TargetPropertiesSP 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 TargetPropertiesSP *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 TargetProperties(nullptr));
+ g_settings_sp_ptr = new TargetPropertiesSP(new TargetProperties(nullptr));
});
- return g_settings_sp;
+ return *g_settings_sp_ptr;
}
Error
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=262090&r1=262089&r2=262090&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Fri Feb 26 17:20:08 2016
@@ -59,13 +59,14 @@ using namespace lldb_private;
const ThreadPropertiesSP &
Thread::GetGlobalProperties()
{
- static ThreadPropertiesSP 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 ThreadPropertiesSP *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 ThreadProperties (true));
+ g_settings_sp_ptr = new ThreadPropertiesSP(new ThreadProperties (true));
});
- return g_settings_sp;
+ return *g_settings_sp_ptr;
}
static PropertyDefinition
More information about the lldb-commits
mailing list