Bug 425985

Summary: Crash in ~DebugSession() when exiting KDevelop during or shortly after debugging a program
Product: [Applications] kdevelop Reporter: Igor Kushnir <igorkuo>
Component: CPP DebuggerAssignee: Igor Kushnir <igorkuo>
Status: RESOLVED FIXED    
Severity: crash CC: niko.sams
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 5.6.1

Description Igor Kushnir 2020-08-30 13:53:39 UTC
SUMMARY
When a user exits KDevelop during or shortly after debugging a program, a DebugSession object may outlive MIDebuggerPlugin. This can cause a crash in ~DebugSession().

SOFTWARE/OS VERSIONS
Manjaro GNU/Linux, Xfce
KDE Frameworks Version: 5.73.0
Qt Version: 5.15.0

ADDITIONAL INFORMATION
I am going to create a Merge Request with a fix soon.

BACKTRACE (RelWithDebInfo)
Application: KDevelop (kdevelop), signal: Segmentation fault

[KCrash Handler]
#4  0x00007f0ec006c66e in KDevMI::GDB::DebugSession::~DebugSession() (this=0x7f0f10003200, __in_chrg=<optimized out>) at /usr/src/debug/kdevelop/plugins/gdb/debugsession.cpp:72
#5  KDevMI::GDB::DebugSession::~DebugSession() (this=0x7f0f10003200, __in_chrg=<optimized out>) at /usr/src/debug/kdevelop/plugins/gdb/debugsession.cpp:73
#6  0x00007f0f27fa5f90 in QObject::event(QEvent*) (this=0x7f0f10003200, e=0x559cab2d1860) at kernel/qobject.cpp:1301
#7  0x00007f0f28c18702 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=<optimized out>, receiver=0x7f0f10003200, e=0x559cab2d1860) at kernel/qapplication.cpp:3671
#8  0x00007f0f27f797ba in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x7f0f10003200, event=0x559cab2d1860) at ../../include/QtCore/5.15.0/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:325
#9  0x00007f0f27f7c2a3 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (receiver=0x0, event_type=0, data=0x559c86efc150) at kernel/qcoreapplication.cpp:1815
#10 0x00007f0f27fd2cf4 in postEventSourceDispatch(GSource*, GSourceFunc, gpointer) (s=0x559c86f6ab90) at kernel/qeventdispatcher_glib.cpp:277
#11 0x00007f0f22bd043c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#12 0x00007f0f22c1e1d9 in  () at /usr/lib/libglib-2.0.so.0
#13 0x00007f0f22bcf221 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#14 0x00007f0f27fd2331 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x559c86f0d9f0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#15 0x00007f0f27f7813c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7ffc4a6179a0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:141
#16 0x00007f0f27f805c4 in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#17 0x0000559c850ac3b1 in main(int, char**) (argc=<optimized out>, argv=0x7ffc4a617b08) at /usr/src/debug/kdevelop/app/main.cpp:850
[Inferior 1 (process 652375) detached]
Comment 1 Igor Kushnir 2020-10-16 14:38:46 UTC
Git commit 89ffddc703cead3400122496d286f060b7dcce43 by Igor Kushnir.
Committed on 15/10/2020 at 15:26.
Pushed by igorkushnir into branch '5.6'.

MIDebugSession::m_plugin: raw pointer => QPointer

When a user exits KDevelop during or shortly after debugging a program,
a DebugSession object may outlive MIDebuggerPlugin. This can cause a
crash in ~DebugSession(). Both GDB::DebugSession and LLDB::DebugSession
already support nullptr m_plugin for testing purposes, so this QPointer
type change alone eliminates the crash.
FIXED-IN: 5.6.1

M  +1    -0    plugins/debuggercommon/midebugsession.cpp
M  +2    -1    plugins/debuggercommon/midebugsession.h

https://invent.kde.org/kdevelop/kdevelop/commit/89ffddc703cead3400122496d286f060b7dcce43