Bug 433180

Summary: Kate crashed in Kate::TextBuffer::notifyAboutRangeChange() opening a file
Product: [Applications] kate Reporter: Christopher Yeleighton <giecrilj>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: christoph, dasmau89, nate
Priority: NOR Keywords: drkonqi
Version: 20.12.2   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 5.82.0
Sentry Crash Report:

Description Christopher Yeleighton 2021-02-18 16:17:49 UTC
Application: kate (20.12.2)

Qt Version: 5.15.2
Frameworks Version: 5.78.0
Operating System: Linux 5.10.16-1-default x86_64
Windowing System: X11
Drkonqi Version: 5.21.0
Distribution: openSUSE Tumbleweed

-- Information about the crash:
- What I was doing when the application crashed:

I saved a file to a removable drive and ejected the drive.  Kate notified me that the file has disappeared and I told Kate to close the buffer.  Then I told Kate to open another file.

The reporter is unsure if this crash is reproducible.

-- Backtrace:
Application: Kate (kate), signal: Segmentation fault

[KCrash Handler]
#4  0x00007f59293d13ee in Kate::TextBuffer::notifyAboutRangeChange(KTextEditor::View*, int, int, bool) () from /usr/lib64/libKF5TextEditor.so.5
#5  0x00007f59294c5975 in ?? () from /usr/lib64/libKF5TextEditor.so.5
#6  0x00007f59294aa498 in KTextEditor::ViewPrivate::updateRendererConfig() () from /usr/lib64/libKF5TextEditor.so.5
#7  0x00007f5929437579 in KTextEditor::DocumentPrivate::updateFileType(QString const&, bool) () from /usr/lib64/libKF5TextEditor.so.5
#8  0x00007f5929427fc2 in KTextEditor::DocumentPrivate::openFile() () from /usr/lib64/libKF5TextEditor.so.5
#9  0x00007f59292c8405 in KParts::ReadOnlyPartPrivate::openLocalFile (this=this@entry=0x7f591c010140) at /usr/src/debug/kparts-5.78.0-1.1.x86_64/src/readonlypart.cpp:177
#10 0x00007f59292cc6ff in KParts::ReadOnlyPart::openUrl (this=0x55813ad85540, url=...) at /usr/src/debug/kparts-5.78.0-1.1.x86_64/src/readonlypart.cpp:140
#11 0x00007f5929429532 in KTextEditor::DocumentPrivate::openUrl(QUrl const&) () from /usr/lib64/libKF5TextEditor.so.5
#12 0x00005581363879fe in ?? ()
#13 0x00005581363b799f in ?? ()
#14 0x00007f59278d6980 in doActivate<false> (sender=0x55813874b520, signal_index=4, argv=argv@entry=0x7ffe6528aec0) at kernel/qobject.cpp:3898
#15 0x00007f59278cfc60 in QMetaObject::activate (sender=sender@entry=0x55813874b520, m=m@entry=0x7f59289850a0, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7ffe6528aec0) at kernel/qobject.cpp:3946
#16 0x00007f5928487f02 in QAction::triggered (this=this@entry=0x55813874b520, _t1=<optimized out>) at .moc/moc_qaction.cpp:376
#17 0x00007f592848a741 in QAction::activate (this=this@entry=0x55813874b520, event=event@entry=QAction::Trigger) at kernel/qaction.cpp:1161
#18 0x00007f5928604a9a in QMenuPrivate::activateCausedStack (this=this@entry=0x5581388bf830, causedStack=..., action=action@entry=0x55813874b520, action_e=action_e@entry=QAction::Trigger, self=self@entry=true) at widgets/qmenu.cpp:1384
#19 0x00007f592860c1d2 in QMenuPrivate::activateAction (this=0x5581388bf830, action=0x55813874b520, action_e=QAction::Trigger, self=<optimized out>) at widgets/qmenu.cpp:1461
#20 0x00007f59284ce34e in QWidget::event (this=0x5581388374c0, event=0x7ffe6528b540) at kernel/qwidget.cpp:9019
#21 0x00007f592848e4ff in QApplicationPrivate::notify_helper (this=this@entry=0x5581381b1e40, receiver=receiver@entry=0x5581388374c0, e=e@entry=0x7ffe6528b540) at kernel/qapplication.cpp:3632
#22 0x00007f59284953eb in QApplication::notify (this=0x7ffe6528b240, receiver=0x5581388374c0, e=0x7ffe6528b540) at kernel/qapplication.cpp:3076
#23 0x00007f59278a032a in QCoreApplication::notifyInternal2 (receiver=0x5581388374c0, event=0x7ffe6528b540) at kernel/qcoreapplication.cpp:1063
#24 0x00007f5928494416 in QApplicationPrivate::sendMouseEvent (receiver=0x5581388374c0, event=event@entry=0x7ffe6528b540, alienWidget=0x0, nativeWidget=0x5581388374c0, buttonDown=buttonDown@entry=0x7f59289bc670 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2614
#25 0x00007f59284e6923 in QWidgetWindow::handleMouseEvent (this=0x7f591c012b30, event=0x7ffe6528b800) at kernel/qwidgetwindow.cpp:580
#26 0x00007f59284e98be in QWidgetWindow::event (this=0x7f591c012b30, event=0x7ffe6528b800) at kernel/qwidgetwindow.cpp:300
#27 0x00007f592848e4ff in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x7f591c012b30, e=0x7ffe6528b800) at kernel/qapplication.cpp:3632
#28 0x00007f59278a032a in QCoreApplication::notifyInternal2 (receiver=0x7f591c012b30, event=0x7ffe6528b800) at kernel/qcoreapplication.cpp:1063
#29 0x00007f5927d0ed03 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib64/libQt5Gui.so.5
#30 0x00007f5927ce4c5c in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Gui.so.5
#31 0x00007f5922dd0faa in ?? () from /usr/lib64/libQt5XcbQpa.so.5
#32 0x00007f59258a7f27 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#33 0x00007f59258a82a8 in ?? () from /usr/lib64/libglib-2.0.so.0
#34 0x00007f59258a835f in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#35 0x00007f59278f78bf in QEventDispatcherGlib::processEvents (this=0x5581382aa4e0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#36 0x00007f592789eceb in QEventLoop::exec (this=this@entry=0x7ffe6528bb30, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#37 0x00007f59278a6f60 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#38 0x0000558136381999 in ?? ()
#39 0x00007f5927208b25 in __libc_start_main () from /lib64/libc.so.6
#40 0x000055813638396e in _start ()
[Inferior 1 (process 10398) detached]

Possible duplicates by query: bug 424983, bug 422546, bug 398452, bug 359427, bug 349340.

Reported using DrKonqi
Comment 1 Christoph Cullmann 2021-04-04 10:34:41 UTC
Git commit ff9ea7a83eb92f2e58a794d80404ba084a9e06ca by Christoph Cullmann.
Committed on 04/04/2021 at 10:31.
Pushed by cullmann into branch 'master'.

fix memory corruption on 'Close the file, discard..'

if you remove some file from the file system
that is open in a KTextEditor document, some
message will show up

if you click the 'Close the file, discarding its content.'
button, we unfortunately delete "this" if the container
application like Kate provides the necessary interface

delay this, like e.g. the vim commands do

(+ guard vim commands by passing context pointer to doc/view)

M  +6    -7    src/document/katedocument.cpp
M  +0    -6    src/document/katedocument.h
M  +2    -2    src/vimode/appcommands.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/ff9ea7a83eb92f2e58a794d80404ba084a9e06ca
Comment 2 Christoph Cullmann 2021-04-06 18:15:29 UTC
*** Bug 435432 has been marked as a duplicate of this bug. ***