Bug 459612

Summary: Kate crashes when using navigation bar with keyboard and LSP
Product: [Applications] kate Reporter: maty78485
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: crash Keywords: drkonqi
Priority: NOR    
Version First Reported In: 22.08.1   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Screen recording of invoking the crash

Description maty78485 2022-09-24 18:31:05 UTC
Application: kate (22.08.1)

Qt Version: 5.15.6
Frameworks Version: 5.98.0
Operating System: Linux 5.13.0-39-generic x86_64
Windowing System: X11
Distribution: KDE neon User - 5.25
DrKonqi: 5.25.5 [KCrashBackend]

-- Information about the crash:
When using LSP server, switching file through navigation bar with keyboard may crash the Kate.
Tested with rust-analyzer, but I believe the issue will show up with other LSP servers too.

It occurs just about 80% of the time

STEPS TO REPRODUCE
Below is how I successfully reproduced the crash, but some of the steps probably aren't needed.

 1. Install rust-analyzer and make sure it correctly works with Kate LSP plugin
 2. Create two files in a same directory named file1.rs and file2.rs, both with content `fn aa() {}`
 3. Check in Settings -> Configure keyboard shortcuts, that action `Focus navigation bar` has assigned shortcut Ctrl+Shift+N
 4. Close Kate
 5. Open `file1.rs` in Kate
 6. Make sure navigation bar is shown
 7. Wait, until LSP server shows `aa[fn()]` as the last item in navigation bar. Without that, crash will most likely won't happen. Sometimes, it's needed to reload the document (F5) to show it.
 8. Press Ctrl+Shift+N to focus the navigation bar
 9. Press left arrow and select `file2.rs` by pressing arrow down
 10. Open file2.rs by pressing Enter
 11. Kate may now crash

The crash can be reproduced sometimes.

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

[New LWP 30472]
[New LWP 30476]
[New LWP 30477]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f09d02f899f in __GI___poll (fds=0x7ffc1a28cab8, nfds=1, timeout=1000) at ../sysdeps/unix/sysv/linux/poll.c:29
__preamble__
[Current thread is 1 (Thread 0x7f09cb5199c0 (LWP 30471))]

Thread 4 (Thread 0x7f09b7fff700 (LWP 30477)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x560bb34c5e70) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x560bb34c5e20, cond=0x560bb34c5e48) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x560bb34c5e48, mutex=0x560bb34c5e20) at pthread_cond_wait.c:647
#3  0x00007f09d068e5eb in QWaitConditionPrivate::wait (deadline=..., this=0x560bb34c5e20) at thread/qwaitcondition_unix.cpp:146
#4  QWaitCondition::wait (this=this@entry=0x560bb2d60a58, mutex=mutex@entry=0x560bb2d60a50, deadline=...) at thread/qwaitcondition_unix.cpp:225
#5  0x00007f09d175c35a in QFileInfoGatherer::run (this=0x560bb2d60a40) at ../../include/QtCore/../../src/corelib/kernel/qdeadlinetimer.h:68
#6  0x00007f09d0688543 in QThreadPrivate::start (arg=0x560bb2d60a40) at thread/qthread_unix.cpp:330
#7  0x00007f09cf07e609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#8  0x00007f09d0305133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7f09c0af8700 (LWP 30476)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x560bb34c1090) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x560bb34c1040, cond=0x560bb34c1068) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x560bb34c1068, mutex=0x560bb34c1040) at pthread_cond_wait.c:647
#3  0x00007f09d068e5eb in QWaitConditionPrivate::wait (deadline=..., this=0x560bb34c1040) at thread/qwaitcondition_unix.cpp:146
#4  QWaitCondition::wait (this=this@entry=0x560bb2ed2c68, mutex=mutex@entry=0x560bb2ed2c60, deadline=...) at thread/qwaitcondition_unix.cpp:225
#5  0x00007f09d175c35a in QFileInfoGatherer::run (this=0x560bb2ed2c50) at ../../include/QtCore/../../src/corelib/kernel/qdeadlinetimer.h:68
#6  0x00007f09d0688543 in QThreadPrivate::start (arg=0x560bb2ed2c50) at thread/qthread_unix.cpp:330
#7  0x00007f09cf07e609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#8  0x00007f09d0305133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7f09ca9a3700 (LWP 30472)):
#0  0x00007f09d02f8a96 in __ppoll (fds=fds@entry=0x7f09c4011d78, nfds=nfds@entry=1, timeout=<optimized out>, timeout@entry=0x0, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:44
#1  0x00007f09d08c5a89 in ppoll (__ss=<optimized out>, __timeout=<optimized out>, __nfds=<optimized out>, __fds=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/poll2.h:77
#2  qt_ppoll (timeout_ts=0x0, nfds=1, fds=0x7f09c4011d78) at kernel/qcore_unix.cpp:132
#3  qt_ppoll (timeout_ts=0x0, nfds=1, fds=0x7f09c4011d78) at kernel/qcore_unix.cpp:129
#4  qt_safe_poll (fds=0x7f09c4011d78, nfds=1, timeout_ts=timeout_ts@entry=0x0) at kernel/qcore_unix.cpp:155
#5  0x00007f09d08c7143 in QEventDispatcherUNIX::processEvents (this=<optimized out>, flags=...) at ../../include/QtCore/../../src/corelib/tools/qarraydata.h:212
#6  0x00007f09d086db3b in QEventLoop::exec (this=this@entry=0x7f09ca9a2bb0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:141
#7  0x00007f09d0687342 in QThread::exec (this=<optimized out>) at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#8  0x00007f09d1a7ff4b in ?? () from /lib/x86_64-linux-gnu/libQt5DBus.so.5
#9  0x00007f09d0688543 in QThreadPrivate::start (arg=0x7f09d1b03d80) at thread/qthread_unix.cpp:330
#10 0x00007f09cf07e609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#11 0x00007f09d0305133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f09cb5199c0 (LWP 30471)):
[KCrash Handler]
#4  QStandardItemPrivate::childIndex (column=0, row=8, this=0x0) at ../../include/QtGui/5.15.6/QtGui/private/../../../../../src/gui/itemmodels/qstandarditemmodel_p.h:166
#5  QStandardItem::child (this=0x560bb3dd9170, row=8, column=0) at itemmodels/qstandarditemmodel.cpp:1884
#6  0x00007f09d11fd4f5 in QStandardItemModelPrivate::itemFromIndex (index=..., this=<optimized out>) at ../../include/QtCore/../../src/corelib/itemmodels/qabstractitemmodel.h:63
#7  QStandardItemModel::data (this=<optimized out>, index=..., role=257) at itemmodels/qstandarditemmodel.cpp:2837
#8  0x00007f09d1d77115 in QModelIndex::data (arole=257, this=0x7ffc1a28db30) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qabstractitemmodel.h:460
#9  BreadCrumbView::onClicked (this=0x560bb36d5fa0, idx=...) at ./apps/lib/kateurlbar.cpp:811
#10 0x00007f09d08a62f2 in QtPrivate::QSlotObjectBase::call (a=0x7ffc1a28db00, r=0x560bb36d5fa0, this=0x560bb2dd5cd0) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#11 doActivate<false> (sender=0x560bb36d5fa0, signal_index=8, argv=0x7ffc1a28db00) at kernel/qobject.cpp:3919
#12 0x00007f09d089f587 in QMetaObject::activate (sender=sender@entry=0x560bb36d5fa0, m=m@entry=0x7f09d1a53c00 <QAbstractItemView::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7ffc1a28db00) at kernel/qobject.cpp:3979
#13 0x00007f09d1792899 in QAbstractItemView::clicked (this=this@entry=0x560bb36d5fa0, _t1=...) at .moc/moc_qabstractitemview.cpp:654
#14 0x00007f09d1d706a1 in BreadCrumbView::openLastIndex (this=0x560bb36d5fa0) at ./apps/lib/kateurlbar.cpp:843
#15 UrlbarContainer::open (this=<optimized out>) at ./apps/lib/kateurlbar.cpp:1010
#16 KateUrlBar::open (this=0x560bb2e7fec0) at ./apps/lib/kateurlbar.cpp:1131
#17 0x00007f09d08a62f2 in QtPrivate::QSlotObjectBase::call (a=0x7ffc1a28dcb0, r=0x560bb2fed970, this=0x560bb2d49a60) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#18 doActivate<false> (sender=0x560bb2e332d0, signal_index=4, argv=0x7ffc1a28dcb0) at kernel/qobject.cpp:3919
#19 0x00007f09d089f587 in QMetaObject::activate (sender=sender@entry=0x560bb2e332d0, m=m@entry=0x7f09d1a351a0 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7ffc1a28dcb0) at kernel/qobject.cpp:3979
#20 0x00007f09d1519986 in QAction::triggered (this=this@entry=0x560bb2e332d0, _t1=<optimized out>) at .moc/moc_qaction.cpp:376
#21 0x00007f09d151c038 in QAction::activate (this=0x560bb2e332d0, event=<optimized out>) at kernel/qaction.cpp:1161
#22 0x00007f09d151c94f in QAction::event (e=<optimized out>, this=<optimized out>) at kernel/qaction.cpp:1086
#23 QAction::event (this=<optimized out>, e=<optimized out>) at kernel/qaction.cpp:1075
#24 0x00007f09d151fe43 in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x560bb2e332d0, e=0x7ffc1a28e030) at kernel/qapplication.cpp:3637
#25 0x00007f09d1528c58 in QApplication::notify(QObject*, QEvent*) () at kernel/qapplication.cpp:3161
#26 0x00007f09d086f03a in QCoreApplication::notifyInternal2 (receiver=0x560bb2e332d0, event=0x7ffc1a28e030) at ../../include/QtCore/5.15.6/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:332
#27 0x00007f09d0e4f3e3 in QShortcutMap::dispatchEvent (this=this@entry=0x560bb298e908, e=e@entry=0x7ffc1a28e0f0) at kernel/qshortcutmap.cpp:675
#28 0x00007f09d0e4fd83 in QShortcutMap::tryShortcut (this=this@entry=0x560bb298e908, e=e@entry=0x7ffc1a28e0f0) at kernel/qshortcutmap.cpp:343
#29 0x00007f09d0dfbb82 in QWindowSystemInterface::handleShortcutEvent (window=<optimized out>, window@entry=0x560bb2e9c750, timestamp=9331401, keyCode=78, modifiers=..., nativeScanCode=57, nativeVirtualKey=78, nativeModifiers=21, text=..., autorepeat=false, count=1) at kernel/qwindowsysteminterface.cpp:477
#30 0x00007f09d0e1cb91 in QGuiApplicationPrivate::processKeyEvent (e=e@entry=0x560bb2f8caf0) at kernel/qguiapplication.cpp:2398
#31 0x00007f09d0e21e4b in QGuiApplicationPrivate::processWindowSystemEvent (e=0x560bb2f8caf0) at kernel/qguiapplication.cpp:2011
#32 0x00007f09d0df86bc in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at kernel/qwindowsysteminterface.cpp:1169
#33 0x00007f09cb0dd207 in QXcbUnixEventDispatcher::processEvents (this=0x560bb2a47c70, flags=...) at qxcbeventdispatcher.cpp:63
#34 0x00007f09d086db3b in QEventLoop::exec (this=this@entry=0x7ffc1a28e360, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:141
#35 0x00007f09d0875ce4 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#36 0x0000560bb0d96d43 in main (argc=<optimized out>, argv=<optimized out>) at ./apps/kate/main.cpp:607
[Inferior 1 (process 30471) detached]

Reported using DrKonqi
Comment 1 maty78485 2022-09-24 18:40:01 UTC
Created attachment 152387 [details]
Screen recording of invoking the crash

Added screen recording of invoking the crash
Comment 2 Waqar Ahmed 2022-09-26 07:39:26 UTC
Git commit 2f7a3f3b4f3afe7760e2e3168a37c4b9b8716273 by Waqar Ahmed.
Committed on 26/09/2022 at 07:39.
Pushed by waqar into branch 'master'.

Fix crash in urlbar

M  +16   -6    apps/lib/kateurlbar.cpp

https://invent.kde.org/utilities/kate/commit/2f7a3f3b4f3afe7760e2e3168a37c4b9b8716273
Comment 3 Waqar Ahmed 2022-09-26 07:41:21 UTC
Git commit 04ba544ea28f4dd840b2d73776ccf049cec7e97f by Waqar Ahmed.
Committed on 26/09/2022 at 07:41.
Pushed by waqar into branch 'release/22.08'.

Fix crash in urlbar
(cherry picked from commit 2f7a3f3b4f3afe7760e2e3168a37c4b9b8716273)

M  +16   -6    apps/lib/kateurlbar.cpp

https://invent.kde.org/utilities/kate/commit/04ba544ea28f4dd840b2d73776ccf049cec7e97f