Bug 450817 - Kate crashes when "Dynamic Word Wrap" is disabled
Summary: Kate crashes when "Dynamic Word Wrap" is disabled
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (show other bugs)
Version: 21.12.2
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-24 23:29 UTC by Prasad Murthy
Modified: 2022-09-23 22:01 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Sampletext for reproduction of the bug (1.91 KB, text/plain)
2022-02-24 23:29 UTC, Prasad Murthy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Prasad Murthy 2022-02-24 23:29:22 UTC
Created attachment 147108 [details]
Sampletext for reproduction of the bug

Steps to reproduce
-------------------------------
1. Save the sampletext.txt file attached with this bug report somewhere
2. run the command "cat sampletext.txt" in konsole and copy the output to the clipboard
3. open kate and paste the output
4. open "Search and replace" feature of kate at the bottom and replace all "\n<space><space>" with "<space>"
5. now disable "Dynamic word wrap" in kate

System information
------------------------------
Operating System: KDE neon 5.24
KDE Plasma Version: 5.24.2
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.3
Kernel Version: 5.13.0-30-generic (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-7400 CPU @ 3.00GHz
Memory: 30.2 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 630

Packages version
--------------------------
libkf5texteditor5 5.91.0-0xneon+20.04+focal+release+build49
kate 4:21.12.2-0xneon+20.04+focal+release+build66

Backtrace
-----------------

(gdb) bt
#0  KateLineLayout::viewLineCount (this=0x0) at /usr/include/c++/9/bits/unique_ptr.h:360
#1  0x00007ffff7d74c14 in KateLayoutCache::lastViewLine (this=this@entry=0x5555565c1890, realLine=<optimized out>) at ./src/render/katelayoutcache.cpp:461
#2  0x00007ffff7d74eb5 in KateLayoutCache::lastViewLine (realLine=<optimized out>, this=0x5555565c1890) at ./src/view/kateview.h:283
#3  KateLayoutCache::viewLineCount (realLine=<optimized out>, this=0x5555565c1890) at ./src/render/katelayoutcache.cpp:466
#4  KateLayoutCache::displayViewLine (this=0x5555565c1890, virtualCursor=..., limitToVisible=limitToVisible@entry=true) at ./src/render/katelayoutcache.cpp:422
#5  0x00007ffff7dc4b11 in KateViewInternal::prepareForDynWrapChange (this=0x55555607e120) at ./src/view/kateviewinternal.cpp:296
#6  0x00007ffff7db74f9 in KTextEditor::ViewPrivate::updateConfig (this=0x5555565bcb80) at ./src/view/kateview.cpp:1948
#7  KTextEditor::ViewPrivate::updateConfig (this=0x5555565bcb80) at ./src/view/kateview.cpp:1940
#8  0x00007ffff7e1837d in KateViewConfig::updateConfig (this=0x5555565bd150) at ./src/utils/kateconfig.cpp:574
#9  0x00007ffff7e1405c in KateConfig::setValue (this=0x5555565bd150, key=<optimized out>, value=...) at ./src/utils/kateconfig.cpp:173
#10 0x00007ffff7da9bc6 in KateViewConfig::setDynWordWrap (on=<optimized out>, this=0x5555565bd150) at ./src/utils/kateconfig.h:1044
#11 KTextEditor::ViewPrivate::toggleDynWordWrap (this=<optimized out>) at ./src/view/kateview.cpp:1783
#12 0x00007ffff5e7e1be in QtPrivate::QSlotObjectBase::call (a=0x7fffffffd2d0, r=0x5555565bcb80, this=0x555556672420) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#13 doActivate<false> (sender=0x555556672010, signal_index=4, argv=0x7fffffffd2d0) at kernel/qobject.cpp:3886
#14 0x00007ffff697f8e6 in QAction::triggered(bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007ffff6981fb8 in QAction::activate(QAction::ActionEvent) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007ffff5e74d39 in QObject::event (this=0x555556672010, e=0x7fffe4004780) at kernel/qobject.cpp:1314
#17 0x00007ffff6982897 in QAction::event(QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007ffff6985dc3 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007ffff698ebb8 in QApplication::notify(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff5e4719a in QCoreApplication::notifyInternal2 (receiver=0x555556672010, event=0x7fffe4004780)
    at ../../include/QtCore/5.15.3/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:332
#21 0x00007ffff5e49aa1 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x555555669ef0) at kernel/qcoreapplication.cpp:1821
#22 0x00007ffff5ea2397 in postEventSourceDispatch (s=0x555555747db0) at kernel/qeventdispatcher_glib.cpp:277
#23 0x00007ffff3d9817d in g_main_dispatch (context=0x7fffec005000) at ../../../glib/gmain.c:3309
#24 g_main_context_dispatch (context=context@entry=0x7fffec005000) at ../../../glib/gmain.c:3974
#25 0x00007ffff3d98400 in g_main_context_iterate (context=context@entry=0x7fffec005000, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../glib/gmain.c:4047
#26 0x00007ffff3d984a3 in g_main_context_iteration (context=0x7fffec005000, may_block=may_block@entry=1) at ../../../glib/gmain.c:4108
#27 0x00007ffff5ea19f2 in QEventDispatcherGlib::processEvents (this=0x55555574f080, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#28 0x00007ffff5e45c9b in QEventLoop::exec (this=this@entry=0x7fffffffd8e0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:141
#29 0x00007ffff5e4de44 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#30 0x00005555555932c5 in main (argc=<optimized out>, argv=<optimized out>) at ./kate/main.cpp:700
(gdb)
Comment 1 groot 2022-02-24 23:38:01 UTC
Reproducible on FreeBSD as well. Note that step 4, "Search and Replace", wants to use the "Escape sequence" mode. For the "copy and paste" part, either left-mouse-button-select and middle-mouse-paste works, or left-select, ctrl-shift-C (in konsole) and ctrl-V (in kate) will do. Both means of copying work. Copyingf from xterm instead of Konsole will also trigger the crash.
Comment 2 Christoph Cullmann 2022-09-23 22:01:37 UTC
Git commit d17440323b93c87ecb7eb73c7b24707485be892a by Christoph Cullmann.
Committed on 23/09/2022 at 22:01.
Pushed by cullmann into branch 'master'.

avoid magic to compute line

better jump a bit in the view on word wrap change instead of
having a hard crash

thanks for the very good reproduction steps inside the bug

M  +0    -2    src/view/kateview.cpp
M  +1    -14   src/view/kateviewinternal.cpp
M  +0    -2    src/view/kateviewinternal.h

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