Bug 447478

Summary: Q_ASSERT crash in screen.cpp when trying to select, searching
Product: [Applications] konsole Reporter: Martin Sandsmark <martin.sandsmark>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED WORKSFORME    
Severity: normal CC: justin.zobel
Priority: NOR    
Version: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Martin Sandsmark 2021-12-24 15:50:29 UTC
Crashing on Q_ASSERT(screenLine <= _screenLinesSize);

screenLine is 437, _screenLinesSize is 61, _columns is 113, the rest of the useful are optimized out.

#0  0x00007f72f8d3cd22 in raise () at /usr/lib/libc.so.6
#1  0x00007f72f8d26862 in abort () at /usr/lib/libc.so.6
#2  0x00007f72f9172f26 in qt_assert(char const*, char const*, int) () at /usr/lib/libQt5Core.so.5
#3  0x00007f72f9172f86 in qt_assert_x(char const*, char const*, char const*, int) () at /usr/lib/libQt5Core.so.5
#4  0x00007f72fa5ab9b4 in Konsole::Screen::copyLineToStream(int, int, int, Konsole::TerminalCharacterDecoder*, bool, bool, QFlags<Konsole::Screen::DecodingOption>) const
    (this=<optimized out>, line=<optimized out>, start=90, count=1, decoder=<optimized out>, appendNewLine=<optimized out>, isBlockSelectionMode=false, options=...) at /usr/src/debug/konsole/src/Screen.cpp:1543
#5  0x00007f72fa5d4884 in Konsole::Screen::writeToStream(Konsole::TerminalCharacterDecoder*, int, int, QFlags<Konsole::Screen::DecodingOption>) const
    (this=0x561ca8a084d0, decoder=0x7ffd7906a840, startIndex=<optimized out>, endIndex=<optimized out>, options=...) at /usr/src/debug/konsole/src/Screen.cpp:1454
#6  0x00007f72fa5d7ca2 in Konsole::Screen::text(int, int, QFlags<Konsole::Screen::DecodingOption>) const (this=this@entry=0x561ca8a084d0, startIndex=50262, endIndex=50262, options=options@entry=...)
    at /usr/src/debug/konsole/src/Screen.cpp:1421
#7  0x00007f72fa5d7e0b in Konsole::Screen::selectedText(QFlags<Konsole::Screen::DecodingOption>) const (this=0x561ca8a084d0, options=options@entry=...) at /usr/src/debug/konsole/src/Screen.cpp:1402
#8  0x00007f72fa5c0c13 in Konsole::Emulation::checkSelectedText() (this=0x561ca8a1af90) at /usr/include/qt/QtCore/qflags.h:121
#9  0x00007f72f938ead3 in  () at /usr/lib/libQt5Core.so.5
#10 0x00007f72fa63037a in Konsole::TerminalDisplay::extendSelection(QPoint const&) (this=this@entry=0x561ca89f07c0, position=...) at /usr/src/debug/konsole/src/terminalDisplay/TerminalDisplay.cpp:1450
#11 0x00007f72fa63091e in Konsole::TerminalDisplay::mouseMoveEvent(QMouseEvent*) (this=0x561ca89f07c0, ev=0x7ffd7906b1a0) at /usr/src/debug/konsole/src/terminalDisplay/TerminalDisplay.cpp:1299
#12 0x00007f72f9e7ea96 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#13 0x00007f72f9e481a6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#14 0x00007f72f9e4cfd7 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#15 0x00007f72f935df8a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#16 0x00007f72f9e4b99f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () at /usr/lib/libQt5Widgets.so.5
#17 0x00007f72f9e9c837 in  () at /usr/lib/libQt5Widgets.so.5
#18 0x00007f72f9e9e3dc in  () at /usr/lib/libQt5Widgets.so.5
#19 0x00007f72f9e481a6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#20 0x00007f72f935df8a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#21 0x00007f72f97c7fa0 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/libQt5Gui.so.5
#22 0x00007f72f97b35e5 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Gui.so.5
#23 0x00007f72f2d89daa in  () at /usr/lib/libQt5XcbQpa.so.5
#24 0x00007f72f935626b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#25 0x00007f72f93619b7 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#26 0x0000561ca776080b in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/konsole/src/main.cpp:242


Seemingly same issue as https://bugs.kde.org/show_bug.cgi?id=440619#c2, which seems to be happening when searching.
Comment 1 Martin Sandsmark 2021-12-24 16:00:11 UTC
There is something very wrong here, it ends up in the "fetch from history" branch when I'm selecting something on screen.

And the code is a bit wonky, the comment says that _screenLinesSize is the same as _screenLines.size(), but it doesn't seem to be always updated (in this case _screenLines.size() is 62, _screenLinesSize is 61).
Comment 2 Martin Sandsmark 2021-12-24 16:24:14 UTC
From trying to reproduce, it seems to be happening sometimes when resizing the window (so things get reflowed), and then double clicking on a highlighted URL.
Comment 3 Martin Sandsmark 2021-12-24 16:32:22 UTC
Can consistently reproduce by double clicking to start word selection, and then moving the cursor over an URL.
Comment 4 Bug Janitor Service 2021-12-24 17:20:51 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/562
Comment 5 Martin Sandsmark 2021-12-28 10:51:09 UTC
Git commit 651ebc2ca600a1d2be91f994aebc1a720f06eea6 by Martin T. H. Sandsmark.
Committed on 24/12/2021 at 17:18.
Pushed by tcanabrava into branch 'master'.

Work around weird position reported from filters.

M  +15   -3    src/terminalDisplay/TerminalDisplay.cpp

https://invent.kde.org/utilities/konsole/commit/651ebc2ca600a1d2be91f994aebc1a720f06eea6
Comment 6 Justin Zobel 2023-02-03 06:00:28 UTC
Did the above commit fix the issue Martin?
Comment 7 Bug Janitor Service 2023-02-18 03:47:07 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 8 Bug Janitor Service 2023-03-05 03:45:47 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!