Commit 79c2b0f6 authored by Igor Kushnir's avatar Igor Kushnir

MIDebugger: check ICore::debugController() for nullptr

When a user exits KDevelop while debugging a program, a queued call to
MIDebugger::readyReadStandardOutput() may be invoked during or after
~CorePrivate(). If this happens after ~DebugController() (which is the
parent of BreakpointModel), a crash is likely, because
readyReadStandardOutput() indirectly calls
MIBreakpointController::updateFromDebugger(), which assumes that
BreakpointModel is not null (as do all other MIBreakpointController's
member functions).

Note that MIDebugger::readyReadStandardOutput() after ~DebugController()
can be invoked both from inside ~MIDebugger() (more precisely, from
inside the QProcess::waitForFinished() call) and before the destructor.

There is no need to process a debugger's standard output and risk a
crash when KDevelop has almost finished shutting down.

BUG: 425993
FIXED-IN: 5.6.1
parent 6a4f671d
......@@ -131,6 +131,16 @@ void MIDebugger::kill()
void MIDebugger::readyReadStandardOutput()
{
auto* const core = KDevelop::ICore::self();
if (!core || !core->debugController()) {
const auto nullObject = core ? QLatin1String("the debug controller")
: QLatin1String("the KDevelop core");
qCDebug(DEBUGGERCOMMON).nospace().noquote()
<< "Cannot process standard output without " << nullObject
<< ". KDevelop must be exiting and " << nullObject << " already destroyed.";
return;
}
m_process->setReadChannel(QProcess::StandardOutput);
m_buffer += m_process->readAll();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment