Revert "Don't leak the debug sessions"
The reverted commit made the debugger plugin a debug session's parent in order to fix test_midbus memory leaks. However, DebugController is responsible for destroying debug sessions, not the debugger plugin. This unique ownership works correctly in KDevelop. See my older fixes: 89ffddc7 and 37ff587e. Potentially destroying a debug session earlier, before the last safe moment in ~DebugController(), may unnecessarily kill its debugger process. With the debugger plugin as a debug session's parent, disabling the GDB plugin while debugging an application breaks debugging and can even cause a crash if MIDebugJob::doKill() accesses a dangling raw pointer m_session. With the session-parenting commit reverted, miraculously, disabling the GDB plugin does not affect debugging, which continues working properly as though nothing has changed; starting a new debug session fails as expected when the GDB plugin is disabled. The reverted commit added MIDebugSession::m_shuttingDown. There are no related crash reports and this data member seems unnecessary. When MIDebugSession does not finish successfully, it is destroyed via MIDebugSession::killDebuggerImpl(), which sets s_dbgNotStarted state and disables the stopDebugger() call in ~MIDebugSession(). I think the leak should be fixed in the test instead. If the test does not use DebugController, it should provide a minimal replacement. If a future proper leak fix triggers a crash again, consider replacing the `if` block that contains the `stopDebugger()` call with `killDebuggerNow()` in ~MIDebugSession() instead of reintroducing MIDebugSession::m_shuttingDown. This reverts commit 1256df11.
parent
2ad75c9e
Please register or sign in to comment