summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Debugger.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2016-07-11 22:50:18 +0000
committerGreg Clayton <gclayton@apple.com>2016-07-11 22:50:18 +0000
commitaacb80853a46bd544fa76a945667302be1de706c (patch)
treed4542fa34cb00f8c7bc65973555e2b556ffd43ef /lldb/source/Core/Debugger.cpp
parent7ef5820fa3878e9428701155d7454c7943a033f4 (diff)
downloadbcm5719-llvm-aacb80853a46bd544fa76a945667302be1de706c.tar.gz
bcm5719-llvm-aacb80853a46bd544fa76a945667302be1de706c.zip
Fixed a threading race condition where we could crash after calling Debugger::Terminate().
The issue was we have two global variables: one that contains a DebuggerList pointer and one that contains a std::mutex pointer. These get initialized in Debugger::Initialize(), and everywhere that uses these does: if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) { std::lock_guard<std::recursive_mutex> guard(*g_debugger_list_mutex_ptr); // do work while mutex is locked } Debugger::Terminate() was deleting and nulling out g_debugger_list_ptr which meant we had a race condition where someone might do the if statement and it evaluates to true, then another thread calls Debugger::Terminate() and deletes and nulls out g_debugger_list_ptr while holding the mutex, and another thread then locks the mutex and tries to use g_debugger_list_ptr. The fix is to just not delete and null out the g_debugger_list_ptr variable. llvm-svn: 275119
Diffstat (limited to 'lldb/source/Core/Debugger.cpp')
-rw-r--r--lldb/source/Core/Debugger.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index dfff06d11a9..34608d0193f 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -462,8 +462,6 @@ Debugger::Terminate ()
for (const auto& debugger: *g_debugger_list_ptr)
debugger->Clear();
g_debugger_list_ptr->clear();
- delete g_debugger_list_ptr;
- g_debugger_list_ptr = nullptr;
}
}
}
OpenPOWER on IntegriCloud