Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion core/debuggercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,8 +1875,18 @@ void DebuggerController::EventHandler(const DebuggerEvent& event)

if (m_accessor)
{
delete m_accessor;
// Defer deletion to a detached thread. The accessor holds a DbgRef<DebuggerController>,
// and if it is the last reference, deleting it here (on the event thread) would trigger
// ~DebuggerController which calls m_debuggerEventThread.join() -- deadlocking/crashing
// because we ARE the event thread.
//
// This can happen when Destroy() races with event processing: EventHandler sets
// ConnectionStatus to NotConnected (line above), and another thread observes this,
// calls Destroy() which removes the global array ref, making the accessor's DbgRef
// the last reference to the controller.
auto* accessor = m_accessor;
m_accessor = nullptr;
std::thread([accessor]() { delete accessor; }).detach();
}
m_lastIP = m_currentIP;
m_currentIP = 0;
Expand Down