Bug 444726 - KDevelop crashes when debugging finishes while an open file has several nested folded nodes
Summary: KDevelop crashes when debugging finishes while an open file has several neste...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.87.0
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2021-10-31 16:33 UTC by Igor Kushnir
Modified: 2021-11-01 13:47 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.88.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Kushnir 2021-10-31 16:33:51 UTC
Application: kdevelop (5.6.40)
 (Compiled from sources)
Qt Version: 5.15.2
Frameworks Version: 5.87.0
Operating System: Linux 5.10.70-1-MANJARO x86_64
Windowing System: X11
Drkonqi Version: 5.22.5
Distribution: Manjaro Linux

-- Information about the crash:
- What I was doing when the application crashed:
1. Fold several non-top-level nodes, then fold their parent nodes.
2. Start debugging.
3. KDevelop crashes as soon as debugging finishes.

I have already implemented a fix and will create a merge request soon.

The crash can be reproduced every time.

-- Backtrace:
Application: KDevelop (kdevelop), signal: Segmentation fault

[KCrash Handler]
#4  0x00007fc1aaf91a2c in Kate::TextFolding::importFoldingRanges(QJsonDocument const&) (this=this@entry=0x557b3834ffd8, folds=...) at /home/Mint14_home/igor/Install/abs/ktexteditor/src/ktexteditor-5.87.0/src/buffer/katetextfolding.cpp:719
#5  0x00007fc1ab082865 in KTextEditor::ViewPrivate::applyFoldingState() (this=this@entry=0x557b3834fe00) at /home/Mint14_home/igor/Install/abs/ktexteditor/src/ktexteditor-5.87.0/src/view/kateview.cpp:3789
#6  0x00007fc1ab08c1db in KTextEditor::ViewPrivate::readSessionConfig(KConfigGroup const&, QSet<QString> const&) (this=0x557b3834fe00, config=..., flags=<optimized out>) at /home/Mint14_home/igor/Install/abs/ktexteditor/src/ktexteditor-5.87.0/src/view/kateview.cpp:1659
#7  0x00007fc1ae60df55 in KDevelop::TextView::readSessionConfig(KConfigGroup&) (this=<optimized out>, config=<optimized out>) at /usr/src/debug/kdevelop/kdevplatform/shell/textdocument.cpp:663
#8  0x00007fc1ae6ae412 in (anonymous namespace)::loadToAreaPrivate(Sublime::Area*, Sublime::AreaIndex*, KConfigGroup const&, QMultiMap<QString, Sublime::View*>&) (area=area@entry=0x557b3750c270, areaIndex=<optimized out>, setGroup=..., recycle=...) at /usr/include/qt/QtCore/qarraydata.h:143
#9  0x00007fc1ae6aefe3 in KDevelop::WorkingSet::loadToArea(Sublime::Area*) (this=this@entry=0x557b3819f670, area=area@entry=0x557b3750c270) at /usr/src/debug/kdevelop/kdevplatform/shell/workingsets/workingset.cpp:455
#10 0x00007fc1ae6a8526 in KDevelop::WorkingSetController::changedWorkingSet(Sublime::Area*, Sublime::Area*, QString const&, QString const&) (this=0x557b373dba90, area=0x557b3750c270, oldArea=0x557b3747bee0, from=..., to=<optimized out>) at /usr/src/debug/kdevelop/kdevplatform/shell/workingsetcontroller.cpp:309
#11 0x00007fc1acd458c5 in  () at /usr/lib/libQt5Core.so.5
#12 0x00007fc1ab29c809 in Sublime::Area::changedWorkingSet(Sublime::Area*, Sublime::Area*, QString const&, QString const&) (this=this@entry=0x557b3750c270, _t1=<optimized out>, _t1@entry=0x557b3750c270, _t2=<optimized out>, _t2@entry=0x557b3747bee0, _t3=..., _t4=...) at /usr/src/debug/build/kdevplatform/sublime/KDevPlatformSublime_autogen/EWIEGA46WW/moc_area.cpp:341
#13 0x00007fc1ab2a06e5 in Sublime::Area::setWorkingSet(QString const&, bool, Sublime::Area*) (this=this@entry=0x557b3750c270, name=..., persistent=<optimized out>, oldArea=oldArea@entry=0x557b3747bee0) at /usr/src/debug/kdevelop/kdevplatform/sublime/area.cpp:470
#14 0x00007fc1ae656366 in KDevelop::DebugController::debuggerStateChanged(KDevelop::IDebugSession::DebuggerState) (this=<optimized out>, state=<optimized out>) at /usr/src/debug/kdevelop/kdevplatform/shell/debugcontroller.cpp:402
#15 0x00007fc1acd458c5 in  () at /usr/lib/libQt5Core.so.5
#16 0x00007fc1ab5c48af in KDevelop::IDebugSession::stateChanged(KDevelop::IDebugSession::DebuggerState) (this=<optimized out>, _t1=<optimized out>) at /usr/src/debug/build/kdevplatform/debugger/KDevPlatformDebugger_autogen/include/moc_idebugsession.cpp:288
#17 0x00007fc13a8e0701 in KDevMI::MIDebugSession::handleDebuggerStateChange(QFlags<KDevMI::DBGStateFlag>, QFlags<KDevMI::DBGStateFlag>) (this=0x557b38f403a0, oldState=..., newState=...) at /usr/src/debug/kdevelop/plugins/debuggercommon/midebugsession.cpp:460
#18 0x00007fc13a8e1656 in KDevMI::MIDebugSession::slotDebuggerExited(bool, QString const&) (this=0x557b38f403a0, abnormal=<optimized out>, msg=...) at /usr/include/qt/QtCore/qflags.h:121
#19 0x00007fc1acd458c5 in  () at /usr/lib/libQt5Core.so.5
#20 0x00007fc13a8d6b68 in KDevMI::MIDebugger::exited(bool, QString const&) (this=this@entry=0x557b38ddc470, _t1=<optimized out>, _t1@entry=false, _t2=...) at /usr/src/debug/build/plugins/debuggercommon/kdevdebuggercommon_autogen/EWIEGA46WW/moc_midebugger.cpp:288
#21 0x00007fc13a8dcfc3 in KDevMI::MIDebugger::processFinished(int, QProcess::ExitStatus) (this=0x557b38ddc470, exitCode=0, exitStatus=<optimized out>) at /usr/src/debug/kdevelop/plugins/debuggercommon/midebugger.cpp:361
#22 0x00007fc1acd458c5 in  () at /usr/lib/libQt5Core.so.5
#23 0x00007fc1acc74c0d in QProcess::finished(int, QProcess::ExitStatus) () at /usr/lib/libQt5Core.so.5
#24 0x00007fc1acc7a7c6 in  () at /usr/lib/libQt5Core.so.5
#25 0x00007fc1acc7a8fe in  () at /usr/lib/libQt5Core.so.5
#26 0x00007fc1acd4591b in  () at /usr/lib/libQt5Core.so.5
#27 0x00007fc1acd48ed4 in QSocketNotifier::activated(QSocketDescriptor, QSocketNotifier::Type, QSocketNotifier::QPrivateSignal) () at /usr/lib/libQt5Core.so.5
#28 0x00007fc1acd49715 in QSocketNotifier::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#29 0x00007fc1ad9f3ff6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#30 0x00007fc1acd0e1ba in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#31 0x00007fc1acd68736 in  () at /usr/lib/libQt5Core.so.5
#32 0x00007fc1a91a54dc in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#33 0x00007fc1a91f9749 in  () at /usr/lib/libglib-2.0.so.0
#34 0x00007fc1a91a2bc1 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#35 0x00007fc1acd67ada in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#36 0x00007fc1acd0ca6b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#37 0x00007fc1acd15258 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#38 0x0000557b355389d6 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/kdevelop/app/main.cpp:855
[Inferior 1 (process 700195) detached]

Reported using DrKonqi
Comment 1 Bug Janitor Service 2021-10-31 16:52:30 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/211
Comment 2 Bug Janitor Service 2021-10-31 16:52:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/211
Comment 3 Igor Kushnir 2021-10-31 17:13:39 UTC
Git commit a0bee71c546059475681c9c669363f8b318f4704 by Igor Kushnir.
Committed on 31/10/2021 at 16:37.
Pushed by cullmann into branch 'master'.

TextFolding::importFoldingRanges: get rid of UB

* Don't use invalidated iterators.
* Clear all folding ranges instead of unfolding them one by one. This is
  both simpler and more efficient.

M  +39   -0    autotests/src/katefoldingtest.cpp
M  +1    -0    autotests/src/katefoldingtest.h
M  +5    -3    src/buffer/katetextfolding.cpp
M  +5    -0    src/buffer/katetextfolding.h

https://invent.kde.org/frameworks/ktexteditor/commit/a0bee71c546059475681c9c669363f8b318f4704