Skip to content

Commit aacb808

Browse files
author
Greg Clayton
committed
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
1 parent 7ef5820 commit aacb808

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

lldb/source/Core/Debugger.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,6 @@ Debugger::Terminate ()
462462
for (const auto& debugger: *g_debugger_list_ptr)
463463
debugger->Clear();
464464
g_debugger_list_ptr->clear();
465-
delete g_debugger_list_ptr;
466-
g_debugger_list_ptr = nullptr;
467465
}
468466
}
469467
}

0 commit comments

Comments
 (0)