Bug 425986 - Crash in BreakpointModel::save() when exiting KDevelop while debugging a program
Summary: Crash in BreakpointModel::save() when exiting KDevelop while debugging a program
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: CPP Debugger (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Igor Kushnir
URL:
Keywords:
: 446944 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-08-30 14:05 UTC by Igor Kushnir
Modified: 2021-12-14 10:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.6.1
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Kushnir 2020-08-30 14:05:56 UTC
SUMMARY
When a user exits KDevelop while debugging a program, a queued call to BreakpointModel::save() may be invoked during Core::cleanup() or perhaps even ~CorePrivate(). If this happens between SessionController::cleanup() (after which ICore::activeSession() starts returning nullptr) and ~DebugController() (which is the parent of BreakpointModel), the result is a crash.

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 (Debug)
Application: KDevelop (kdevelop), signal: Segmentation fault

[KCrash Handler]
#4  KDevelop::BreakpointModel::save() (this=0x564f7ca2ba50) at ../kdevplatform/debugger/breakpoint/breakpointmodel.cpp:577
#5  0x00007f2cb0feb312 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KDevelop::BreakpointModel::*)()>::call(void (KDevelop::BreakpointModel::*)(), KDevelop::BreakpointModel*, void**) (f=(void (KDevelop::BreakpointModel::*)(KDevelop::BreakpointModel * const)) 0x7f2cb0fe81c2 <KDevelop::BreakpointModel::save()>, o=0x564f7ca2ba50, arg=0x564f89f690a8) at /usr/include/qt/QtCore/qobjectdefs_impl.h:152
#6  0x00007f2cb0feaed6 in QtPrivate::FunctionPointer<void (KDevelop::BreakpointModel::*)()>::call<QtPrivate::List<>, void>(void (KDevelop::BreakpointModel::*)(), KDevelop::BreakpointModel*, void**) (f=(void (KDevelop::BreakpointModel::*)(KDevelop::BreakpointModel * const)) 0x7f2cb0fe81c2 <KDevelop::BreakpointModel::save()>, o=0x564f7ca2ba50, arg=0x564f89f690a8) at /usr/include/qt/QtCore/qobjectdefs_impl.h:185
#7  0x00007f2cb0fea918 in QtPrivate::QSlotObject<void (KDevelop::BreakpointModel::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x564f84c06f90, r=0x564f7ca2ba50, a=0x564f89f690a8, ret=0x0) at /usr/include/qt/QtCore/qobjectdefs_impl.h:418
#8  0x00007f2cb18191d2 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#9  0x00007f2cb2670702 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#10 0x00007f2cb17ec7ba in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#11 0x00007f2cb17ef2a3 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt5Core.so.5
#12 0x00007f2cb1845cf4 in  () at /usr/lib/libQt5Core.so.5
#13 0x00007f2caf6d443c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#14 0x00007f2caf7221d9 in  () at /usr/lib/libglib-2.0.so.0
#15 0x00007f2caf6d3221 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#16 0x00007f2cb1845331 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#17 0x00007f2cb17eb13c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#18 0x00007f2cb17f35c4 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#19 0x0000564f7b86281f in main(int, char**) (argc=3, argv=0x7fff07732518) at ../app/main.cpp:850
[Inferior 1 (process 49588) detached]
Comment 1 Igor Kushnir 2020-10-16 14:39:02 UTC
Git commit c60e8303829be4f13fd4511eda3d4365572c74e6 by Igor Kushnir.
Committed on 15/10/2020 at 15:26.
Pushed by igorkushnir into branch '5.6'.

Check ICore::activeSession() for nullptr in BreakpointModel::save()

When a user exits KDevelop while debugging a program, a queued call to
BreakpointModel::save() may be invoked during Core::cleanup() or perhaps
even during ~CorePrivate(). If this happens between
SessionController::cleanup() and ~DebugController() (which is the parent
of BreakpointModel), the result is a crash. A breakpoint change that is
saved at this time is likely unimportant and can be safely skipped.
FIXED-IN: 5.6.1

M  +8    -1    kdevplatform/debugger/breakpoint/breakpointmodel.cpp

https://invent.kde.org/kdevelop/kdevelop/commit/c60e8303829be4f13fd4511eda3d4365572c74e6
Comment 2 Igor Kushnir 2021-12-14 10:10:24 UTC
*** Bug 446944 has been marked as a duplicate of this bug. ***