File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1875,8 +1875,18 @@ void DebuggerController::EventHandler(const DebuggerEvent& event)
18751875
18761876 if (m_accessor)
18771877 {
1878- delete m_accessor;
1878+ // Defer deletion to a detached thread. The accessor holds a DbgRef<DebuggerController>,
1879+ // and if it is the last reference, deleting it here (on the event thread) would trigger
1880+ // ~DebuggerController which calls m_debuggerEventThread.join() -- deadlocking/crashing
1881+ // because we ARE the event thread.
1882+ //
1883+ // This can happen when Destroy() races with event processing: EventHandler sets
1884+ // ConnectionStatus to NotConnected (line above), and another thread observes this,
1885+ // calls Destroy() which removes the global array ref, making the accessor's DbgRef
1886+ // the last reference to the controller.
1887+ auto * accessor = m_accessor;
18791888 m_accessor = nullptr ;
1889+ std::thread ([accessor]() { delete accessor; }).detach ();
18801890 }
18811891 m_lastIP = m_currentIP;
18821892 m_currentIP = 0 ;
You can’t perform that action at this time.
0 commit comments