KatePart causes Konqueror to crash when using the :q! Vi command

Stefano Crocco stefano.crocco at alice.it
Sun Mar 24 11:04:34 GMT 2024


Hello to everyone,
I hope this is the correct place to ask for information about a crash 
regarding Kate part. If not, sorry for the noise.

A user reported a bug [1] for Konqueror, stating that when opening a text 
document in Konqueror using Kate part and using the Vi command :q! Konqueror 
crashes. According to the attached backtrace, the crash comes from within 
KTextEditor, but I'm not sure it's a bug within the framework itself or it's 
Konqueror which is using it in the wrong way.

According to the attached backtrace (from KTextEditor 6.0.0), the crash 
happens in AppCommands::closeCurrentDocument() (line 302 of appcommands.cpp). 
The problem seems to be that AppCommands::closeCurrentDocument() calls 
activeView()->document() but activeView() is nullptr. According to the 
documentation for KTextEditor::MainWindow::activeView( ), this is expected if 
the active view is not available. I think there are the following 
possibilities:
- closeCurrentDocument correctly assumes that in this situation activeView() 
should not return nullptr. The fact that it returns nullptr is caused by 
Konqueror not using KTextEditor correctly
- as above, but it's KTextEditor which fails to correctly set the active view
- closeCurrentDocument is wrong in assuming that activeView() is valid and 
should check whether this is true before using it.

Without any knowledge of the internals of KTextEditor, I'd say that it makes 
sense for activeView() not to be nullptr, since the user just typed a command 
from within it, so I think the first two possibilities are the most likely. 
Konqueror itself doesn't do anything special with the part: it creates it 
using KPluginFactory::create and puts it inside a tab view, just as it does 
with any other part.

Could anyone tell me if it's Konqueror doing something wrong (and maybe give 
me a hint about what it's doing wrong) or it's a problem within KatePart 
itself?

Thanks in advance

Stefano

[1] https://bugs.kde.org/show_bug.cgi?id=482436
-------------- next part --------------
#0 KateVi::AppCommands::closeCurrentDocument() at /usr/src/debug/kde-frameworks/ktexteditor-6.0.0/ktexteditor-6.0.0/src/vimode/appcommands.cpp:302
#1 QObject::event() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/kernel/qobject.cpp:1.437
#2 QApplicationPrivate::notify_helper() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/widgets/kernel/qapplication.cpp:3.296
#3 QCoreApplication::notifyInternal2() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/kernel/qcoreapplication.cpp:1.121
#4 QCoreApplication::sendEvent() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/kernel/qcoreapplication.cpp:1.539
#5 QCoreApplicationPrivate::sendPostedEvents() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/kernel/qcoreapplication.cpp:1.901
#6 QCoreApplication::sendPostedEvents() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/kernel/qcoreapplication.cpp:1.760
#7 postEventSourceDispatch() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/kernel/qeventdispatcher_glib.cpp:243
#8 g_main_dispatch() at /usr/lib64/libglib-2.0.so.0
#9 g_main_context_iterate_unlocked.isra() at /usr/lib64/libglib-2.0.so.0
#10 g_main_context_iteration() at /usr/lib64/libglib-2.0.so.0
#11 QEventDispatcherGlib::processEvents() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/kernel/qeventdispatcher_glib.cpp:393
#12 QEventLoop::exec() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/global/qflags.h:34
#13 QCoreApplication::exec() at /var/tmp/portage/dev-qt/qtbase-6.6.2/work/qtbase-everywhere-src-6.6.2/src/corelib/global/qflags.h:74
#14 KonquerorApplication::startFirstInstance() at /home/stefano/documenti/programmi/konqueror-development/konqueror/src/konqapplication.cpp:272
#15 KonquerorApplication::start() at /home/stefano/documenti/programmi/konqueror-development/konqueror/src/konqapplication.cpp:335
#16 main() at /home/stefano/documenti/programmi/konqueror-development/konqueror/src/konqmain.cpp:18


More information about the Kde-frameworks-devel mailing list