Bug 427386 - Segfault in ProjectController::reparseProject()=>...=>RunController::checkState() when exiting KDevelop soon after a large project is opened
Summary: Segfault in ProjectController::reparseProject()=>...=>RunController::checkSta...
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Unclassified
Component: general (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: Igor Kushnir
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-06 12:16 UTC by Igor Kushnir
Modified: 2020-10-07 10:24 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.6.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Kushnir 2020-10-06 12:16:51 UTC
SUMMARY
When a user exits KDevelop right after a large project is opened, before ParseProjectJob::start() returns, RunController may be destroyed in the time between `job->start();` and `checkState();` statements in RunController::registerJob(). The result is a segmentation fault in RunController::checkState().

SOFTWARE/OS VERSIONS
Manjaro GNU/Linux, Xfce
KDE Frameworks Version: 5.74.0
Qt Version: 5.15.1

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

BACKTRACE (Release)
Application: KDevelop (kdevelop), signal: Segmentation fault
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f8b392eebc0 (LWP 120878))]

Thread 1 (Thread 0x7f8b392eebc0 (LWP 120878)):
[KCrash Handler]
#6  0x00007f8b51b43089 in KDevelop::RunController::checkState() () at /usr/lib/libKDevPlatformShell.so.55
#7  0x00007f8b51b442b9 in KDevelop::RunController::registerJob(KJob*) () at /usr/lib/libKDevPlatformShell.so.55
#8  0x00007f8b51b0c09a in KDevelop::ProjectController::reparseProject(KDevelop::IProject*, bool, bool) () at /usr/lib/libKDevPlatformShell.so.55
#9  0x00007f8b51b0f0ab in KDevelop::ProjectController::projectImportingFinished(KDevelop::IProject*) () at /usr/lib/libKDevPlatformShell.so.55
#10 0x00007f8b5029250e in  () at /usr/lib/libQt5Core.so.5
#11 0x00007f8b5058ce4d in KJob::result(KJob*, KJob::QPrivateSignal) () at /usr/lib/libKF5CoreAddons.so.5
#12 0x00007f8b5058d93c in KJob::finishJob(bool) () at /usr/lib/libKF5CoreAddons.so.5
#13 0x00007f8b51a29945 in KDevelop::ExecuteCompositeJob::slotResult(KJob*) () at /usr/lib/libKDevPlatformUtil.so.55
#14 0x00007f8b5029250e in  () at /usr/lib/libQt5Core.so.5
#15 0x00007f8b5058ce4d in KJob::result(KJob*, KJob::QPrivateSignal) () at /usr/lib/libKF5CoreAddons.so.5
#16 0x00007f8b5058d93c in KJob::finishJob(bool) () at /usr/lib/libKF5CoreAddons.so.5
#17 0x00007f8b4eacb5a1 in  () at /usr/lib/libKDevPlatformProject.so.55
#18 0x00007f8b5028a30a in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#19 0x00007f8b50f00362 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#20 0x00007f8b50f09819 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#21 0x00007f8b5025ca12 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#22 0x00007f8b5025f276 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt5Core.so.5
#23 0x00007f8b502b5a84 in  () at /usr/lib/libQt5Core.so.5
#24 0x00007f8b4c48b9be in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#25 0x00007f8b4c48d831 in  () at /usr/lib/libglib-2.0.so.0
#26 0x00007f8b4c48d871 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#27 0x00007f8b502b50d0 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#28 0x00007f8b5025b57c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#29 0x00007f8b50263586 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#30 0x00005650c1032bd5 in  ()
#31 0x00007f8b4fc2d023 in __libc_start_main () at /usr/lib/libc.so.6
#32 0x00005650c10337ee in _start ()
[Inferior 1 (process 120878) detached]
Comment 1 Igor Kushnir 2020-10-07 10:24:01 UTC
Git commit 89077c7c9d97ab98fe832958afb5ab24d0dbae44 by Igor Kushnir.
Committed on 07/10/2020 at 10:11.
Pushed by igorkushnir into branch '5.6'.

Don't process events in ParseProjectJob::start()

>From KJob::start() documentation:
Warning: Never implement any synchronous workload in this method.
This method should just trigger the job startup, not do any work itself.
It is expected to be non-blocking.

When a user exits KDevelop in the ParseProjectJob::start()'s nested
event loop, RunController may be destroyed in the time between
`job->start();` and `checkState();` statements in
RunController::registerJob(). The result is a segmentation fault in
RunController::checkState().
FIXED-IN: 5.6.1

M  +9    -0    kdevplatform/language/backgroundparser/parseprojectjob.cpp
M  +1    -0    kdevplatform/language/backgroundparser/parseprojectjob.h

https://invent.kde.org/kdevelop/kdevelop/commit/89077c7c9d97ab98fe832958afb5ab24d0dbae44