Bug 422546

Summary: Kate crashes after file is deleted
Product: [Applications] kate Reporter: Tony <jodr666>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: christoph
Priority: NOR Keywords: drkonqi
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Tony 2020-06-06 19:34:19 UTC
Application: kate (20.07.70)

Qt Version: 5.15.0
Frameworks Version: 5.71.0
Operating System: Linux 5.6.14-1-default x86_64
Windowing system: X11
Distribution: "openSUSE Tumbleweed"

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

Had a single file opened in kate, i deleted said file the crash pop a while after.

To reproduced the crash : 

Create a text file in /var/ with some content.
Open said file with krunner > kate /var/file.
Remove it from /var with : rm file. 
When kate promps about the deleted file chose close file.
Minimize and maximized kate's window then close it.
Watch the sad face pop.

The crash can be reproduced every time.

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

[KCrash Handler]
#4  std::__atomic_base<int>::load (__m=std::memory_order_relaxed, this=0x55cccc0e68d0) at /usr/include/c++/9/bits/atomic_base.h:419
#5  QAtomicOps<int>::loadRelaxed<int> (_q_value=...) at /usr/include/qt5/QtCore/qatomic_cxx11.h:239
#6  QBasicAtomicInteger<int>::loadRelaxed (this=0x55cccc0e68d0) at /usr/include/qt5/QtCore/qbasicatomic.h:107
#7  QtPrivate::RefCount::ref (this=0x55cccc0e68d0) at /usr/include/qt5/QtCore/qrefcount.h:55
#8  QList<KTextEditor::View*>::QList (this=<optimized out>, l=..., this=<optimized out>, l=...) at /usr/include/qt5/QtCore/qlist.h:856
#9  0x00007fb39d02ee28 in KTextEditor::DocumentPrivate::views (this=<optimized out>) at /usr/src/debug/ktexteditor-5.71.0git.20200531T201936~d721c55d-ku.14.1.x86_64/src/document/katedocument.h:150
#10 Kate::TextBuffer::notifyAboutRangeChange (this=<optimized out>, view=0x55cecb69ef90, startLine=-1, endLine=-1, rangeWithAttribute=true) at /usr/src/debug/ktexteditor-5.71.0git.20200531T201936~d721c55d-ku.14.1.x86_64/src/buffer/katetextbuffer.cpp:1006
#11 0x00007fb39d024bd8 in Kate::TextRange::~TextRange (this=<optimized out>, this=<optimized out>) at /usr/src/debug/ktexteditor-5.71.0git.20200531T201936~d721c55d-ku.14.1.x86_64/src/buffer/katetextrange.cpp:65
#12 0x00007fb39d024c29 in Kate::TextRange::~TextRange (this=<optimized out>, this=<optimized out>) at /usr/src/debug/ktexteditor-5.71.0git.20200531T201936~d721c55d-ku.14.1.x86_64/src/buffer/katetextrange.cpp:67
#13 0x00007fb39cf61275 in KateViewInternal::~KateViewInternal (this=<optimized out>, this=<optimized out>) at /usr/src/debug/ktexteditor-5.71.0git.20200531T201936~d721c55d-ku.14.1.x86_64/src/view/kateviewinternal.cpp:293
#14 0x00007fb39cf613f9 in KateViewInternal::~KateViewInternal (this=<optimized out>, this=<optimized out>) at /usr/src/debug/ktexteditor-5.71.0git.20200531T201936~d721c55d-ku.14.1.x86_64/src/view/kateviewinternal.cpp:298
#15 0x00007fb39cf79801 in KTextEditor::ViewPrivate::~ViewPrivate (this=<optimized out>, this=<optimized out>) at /usr/src/debug/ktexteditor-5.71.0git.20200531T201936~d721c55d-ku.14.1.x86_64/src/view/kateview.cpp:263
#16 0x00007fb39cf79b09 in KTextEditor::ViewPrivate::~ViewPrivate (this=<optimized out>, this=<optimized out>) at /usr/src/debug/ktexteditor-5.71.0git.20200531T201936~d721c55d-ku.14.1.x86_64/src/view/kateview.cpp:278
#17 0x00007fb39b403bfe in QObjectPrivate::deleteChildren (this=this@entry=0x55cecb772a10) at kernel/qobject.cpp:2104
#18 0x00007fb39bfaab86 in QWidget::~QWidget (this=0x55cecb71eff0, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1523
#19 0x00007fb39c120fb9 in QStackedWidget::~QStackedWidget (this=0x55cecb71eff0, __in_chrg=<optimized out>) at widgets/qstackedwidget.cpp:145
#20 0x00007fb39b403bfe in QObjectPrivate::deleteChildren (this=this@entry=0x55cecb7195f0) at kernel/qobject.cpp:2104
#21 0x00007fb39bfaab86 in QWidget::~QWidget (this=0x55cecb728260, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1523
#22 0x000055cec951872a in KateViewSpace::~KateViewSpace (this=<optimized out>, this=<optimized out>) at /usr/src/debug/kate-20.07.70git.20200529T063028~f63d953cc-ku.24.1.x86_64/kate/kateviewspace.h:37
#23 KateViewSpace::~KateViewSpace (this=<optimized out>, this=<optimized out>) at /usr/src/debug/kate-20.07.70git.20200529T063028~f63d953cc-ku.24.1.x86_64/kate/kateviewspace.h:37
#24 0x00007fb39b403bfe in QObjectPrivate::deleteChildren (this=this@entry=0x55cecb6a67d0) at kernel/qobject.cpp:2104
#25 0x00007fb39bfaab86 in QWidget::~QWidget (this=0x55cecb650420, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1523
#26 0x000055cec951bd09 in KateViewManager::~KateViewManager (this=<optimized out>, this=<optimized out>) at /usr/src/debug/kate-20.07.70git.20200529T063028~f63d953cc-ku.24.1.x86_64/kate/kateviewmanager.cpp:117
#27 0x000055cec953fd0a in KateMainWindow::~KateMainWindow (this=<optimized out>, this=<optimized out>) at /usr/src/debug/kate-20.07.70git.20200529T063028~f63d953cc-ku.24.1.x86_64/kate/katemainwindow.cpp:211
#28 0x000055cec953ffc9 in KateMainWindow::~KateMainWindow (this=<optimized out>, this=<optimized out>) at /usr/src/debug/kate-20.07.70git.20200529T063028~f63d953cc-ku.24.1.x86_64/kate/katemainwindow.cpp:217
#29 0x00007fb39b406e0f in QObject::event (this=this@entry=0x55cecb5b66c0, e=e@entry=0x55cecc0b10c0) at kernel/qobject.cpp:1301
#30 0x00007fb39bfaf105 in QWidget::event (this=this@entry=0x55cecb5b66c0, event=event@entry=0x55cecc0b10c0) at kernel/qwidget.cpp:9088
#31 0x00007fb39c0c4ab4 in QMainWindow::event (this=0x55cecb5b66c0, event=0x55cecc0b10c0) at widgets/qmainwindow.cpp:1341
#32 0x00007fb39ca1a293 in KMainWindow::event (this=<optimized out>, ev=<optimized out>) at /usr/src/debug/kxmlgui-5.71.0git.20200519T071446~08ab543-ku.6.1.x86_64/src/kmainwindow.cpp:868
#33 0x00007fb39c9ecb19 in KXmlGuiWindow::event (this=0x55cecb5b66c0, ev=0x55cecc0b10c0) at /usr/src/debug/kxmlgui-5.71.0git.20200519T071446~08ab543-ku.6.1.x86_64/src/kxmlguiwindow.cpp:121
#34 0x00007fb39bf6ccdf in QApplicationPrivate::notify_helper (this=this@entry=0x55cecb30f280, receiver=receiver@entry=0x55cecb5b66c0, e=e@entry=0x55cecc0b10c0) at kernel/qapplication.cpp:3671
#35 0x00007fb39bf75b60 in QApplication::notify (this=0x7ffc23311570, receiver=0x55cecb5b66c0, e=0x55cecc0b10c0) at kernel/qapplication.cpp:3417
#36 0x00007fb39b3da6fa in QCoreApplication::notifyInternal2 (receiver=0x55cecb5b66c0, event=0x55cecc0b10c0) at ../../include/QtCore/5.15.0/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:325
#37 0x00007fb39b3dcf71 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x55cecb30e870) at kernel/qcoreapplication.cpp:1815
#38 0x00007fb39b4339a3 in postEventSourceDispatch (s=0x55cecb3e6ae0) at kernel/qeventdispatcher_glib.cpp:277
#39 0x00007fb3993ab6e8 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#40 0x00007fb3993aba70 in ?? () from /usr/lib64/libglib-2.0.so.0
#41 0x00007fb3993abaff in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#42 0x00007fb39b43300e in QEventDispatcherGlib::processEvents (this=0x55cecb3ea190, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#43 0x00007fb39b3d92eb in QEventLoop::exec (this=this@entry=0x7ffc23311310, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:141
#44 0x00007fb39b3e1200 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#45 0x000055cec94f74cd in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/kate-20.07.70git.20200529T063028~f63d953cc-ku.24.1.x86_64/kate/main.cpp:633
[Inferior 1 (process 19843) detached]

Possible duplicates by query: bug 422092, bug 420495, bug 417542, bug 414147, bug 413706.

Reported using DrKonqi
Comment 1 Christoph Cullmann 2020-06-12 18:41:28 UTC
Good catch :/
Bad cleanup order.
Will fix this.
Comment 2 Christoph Cullmann 2020-06-12 18:42:56 UTC
Git commit e35594ef5d2cf1e66682270a47c0d9d458cc9412 by Christoph Cullmann.
Committed on 12/06/2020 at 18:44.
Pushed by cullmann into branch 'master'.

fix crash on view deletion if ranges are still alive

M  +8    -1    src/document/katedocument.cpp
M  +10   -4    src/view/kateview.cpp

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