Bug 457392 - Kate crashes when calling wordLeft on column 1 of a line of length 1
Summary: Kate crashes when calling wordLeft on column 1 of a line of length 1
Status: RESOLVED FIXED
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-01 22:42 UTC by Pablo
Modified: 2022-08-03 03:57 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.97


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pablo 2022-08-01 22:42:08 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Open a new file in Kate
2. press any letter
3. press Ctrl+Left

OBSERVED RESULT
Kate crashes.

    Thread 1 "kate" received signal SIGABRT, Aborted.
    0x00007ffff63b8ce1 in raise () from /lib/x86_64-linux-gnu/libc.so.6
    (gdb) bt
    #0  0x00007ffff63b8ce1 in raise () from /lib/x86_64-linux-gnu/libc.so.6
    #1  0x00007ffff63a2537 in abort () from /lib/x86_64-linux-gnu/libc.so.6
    #2  0x00007ffff67a0bf1 in QMessageLogger::fatal(char const*, ...) const ()
       from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #3  0x00007ffff67a0040 in qt_assert(char const*, char const*, int) ()
       from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #4  0x00007ffff5eafb98 in QString::at (this=0x55555a10d230, i=-1)
        at /usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1072
    #5  0x00007ffff6065446 in CamelCursor::operator+= (this=0x7fffffffbf70, n=-1)
        at /home/p4bl0/projects/kde/src/frameworks/ktexteditor/src/view/kateviewinternal.cpp:1369
    #6  0x00007ffff6065816 in CamelCursor::operator-= (this=0x7fffffffbf70, n=1)
        at /home/p4bl0/projects/kde/src/frameworks/ktexteditor/src/view/kateviewinternal.cpp:1423
    #7  0x00007ffff6063d3c in CalculatingCursor::operator-- (this=0x7fffffffbf70)
        at /home/p4bl0/projects/kde/src/frameworks/ktexteditor/src/view/kateviewinternal.cpp:961
    #8  0x00007ffff6050bd8 in operator() (__closure=0x7fffffffc1d8, cursor=...)
        at /home/p4bl0/projects/kde/src/frameworks/ktexteditor/src/view/kateviewinternal.cpp:1500
    #9  0x00007ffff6050ff5 in KateViewInternal::wordPrev (this=0x55555a41eca0, sel=false)
        at /home/p4bl0/projects/kde/src/frameworks/ktexteditor/src/view/kateviewinternal.cpp:1530
    #10 0x00007ffff6035a76 in KTextEditor::ViewPrivate::wordLeft (this=0x55555aa62bb0)
        at /home/p4bl0/projects/kde/src/frameworks/ktexteditor/src/view/kateview.cpp:3860
    #11 0x00007ffff60486ed in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KTextEditor::ViewPrivate::*)()>::call(void (KTextEditor::ViewPrivate::*)(), KTextEditor::ViewPrivate*, void**) (
        f=(void (KTextEditor::ViewPrivate::*)(KTextEditor::ViewPrivate * const)) 0x7ffff6035a08 <KTextEditor::ViewPrivate::wordLeft()>, o=0x55555aa62bb0, arg=0x7fffffffc400)
        at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152
    #12 0x00007ffff6046f1b in QtPrivate::FunctionPointer<void (KTextEditor::ViewPrivate::*)()>::call<QtP--Type <RET> for more, q to quit, c to continue without paging--
    rivate::List<>, void>(void (KTextEditor::ViewPrivate::*)(), KTextEditor::ViewPrivate*, void**) (
        f=(void (KTextEditor::ViewPrivate::*)(KTextEditor::ViewPrivate * const)) 0x7ffff6035a08 <KTextEditor::ViewPrivate::wordLeft()>, o=0x55555aa62bb0, arg=0x7fffffffc400)
        at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185
    #13 0x00007ffff60442ab in QtPrivate::QSlotObject<void (KTextEditor::ViewPrivate::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, 
        this_=0x55555ab51510, r=0x55555aa62bb0, a=0x7fffffffc400, ret=0x0)
        at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:418
    #14 0x00007ffff69f35a6 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #15 0x00007ffff760fb62 in QAction::triggered(bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
    #16 0x00007ffff76123a1 in QAction::activate(QAction::ActionEvent) ()
       from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
    #17 0x00007ffff7612f67 in QAction::event(QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
    #18 0x00007ffff761615f in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
       from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
    #19 0x00007ffff69bcfca in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
       from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #20 0x00007ffff6f5bcab in QShortcutMap::dispatchEvent(QKeyEvent*) ()
       from /lib/x86_64-linux-gnu/libQt5Gui.so.5
    #21 0x00007ffff6f5c66b in QShortcutMap::tryShortcut(QKeyEvent*) ()
       from /lib/x86_64-linux-gnu/libQt5Gui.so.5
    #22 0x00007ffff6f05cae in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
    #23 0x00007ffff6f284cb in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
    #24 0x00007ffff0caf6b8 in ?? ()
    --Type <RET> for more, q to quit, c to continue without paging--
       from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so
    #25 0x00007ffff69f35a6 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #26 0x00007ffff6cbeb8f in QDBusPendingCallWatcher::finished(QDBusPendingCallWatcher*) ()
       from /lib/x86_64-linux-gnu/libQt5DBus.so.5
    #27 0x00007ffff69e8ff1 in QObject::event(QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #28 0x00007ffff761615f in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
       from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
    #29 0x00007ffff69bcfca in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
       from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #30 0x00007ffff69bfa01 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
       from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #31 0x00007ffff6a14e93 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #32 0x00007ffff404fe6b in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #33 0x00007ffff4050118 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #34 0x00007ffff40501cf in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #35 0x00007ffff6a1451f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #36 0x00007ffff69bb98b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
       from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #37 0x00007ffff69c3c00 in QCoreApplication::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
    #38 0x0000555555561c24 in main (argc=1, argv=0x7fffffffdcf8)
        at /home/p4bl0/projects/kde/src/kde/applications/kate/apps/kate/main.cpp:607


EXPECTED RESULT
Cursor moves back to the beginning of the line.


SOFTWARE/OS VERSIONS
Linux: Debian stable
KDE Plasma Version: 5.20.5
KDE Frameworks Version: Kate and KTextEditor and all their dependencies are compiled from master branches
Qt Version: 5.15.2

ADDITIONAL INFORMATION
I will try to submit a fix asap :).
Comment 1 Pablo 2022-08-01 22:47:05 UTC
It was actually a lot more easy than I thought it would be.
 
Proposed fix: https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/395
Comment 2 Christoph Cullmann 2022-08-02 11:57:01 UTC
Git commit 985ea47ec9064622065bc0b067cb1183b8eed858 by Christoph Cullmann, on behalf of Pablo Rauzy.
Committed on 02/08/2022 at 11:56.
Pushed by cullmann into branch 'master'.

fix crash

Simple fix for this bug that I found and is easy to reproduce: https://bugs.kde.org/show_bug.cgi?id=457392

M  +1    -1    src/view/kateviewinternal.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/985ea47ec9064622065bc0b067cb1183b8eed858