[Lldb-commits] [lldb] r275119 - Fixed a threading race condition where we could crash after calling Debugger::Terminate().
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 11 15:50:18 PDT 2016
Date: Mon Jul 11 17:50:18 2016
New Revision: 275119
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)
// 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.
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Mon Jul 11 17:50:18 2016
@@ -462,8 +462,6 @@ Debugger::Terminate ()
for (const auto& debugger: *g_debugger_list_ptr)
- delete g_debugger_list_ptr;
- g_debugger_list_ptr = nullptr;
More information about the lldb-commits