Bug 466874

Summary: Konsole crashes during resize of a TUI program
Product: [Applications] konsole Reporter: jeremy
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: crash CC: arcadiy, blubberdiblub
Priority: NOR Keywords: drkonqi
Version: 22.12.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description jeremy 2023-03-05 10:56:20 UTC
Application: konsole (22.12.3)

Qt Version: 5.15.8
Frameworks Version: 5.103.0
Operating System: Linux 6.2.2-zen1-1-zen x86_64
Windowing System: X11
Distribution: "Arch Linux"
DrKonqi: 5.27.2 [KCrashBackend]

-- Information about the crash:
After launching https://github.com/kescherCode/MultiCube (or any other TUI that doesn't dynamically resize and print a lot of characters to the screen) and repeatedly resizing the Konsole window, when making the window smaller, I rather consistently encounter this exact crash. It may be related to one other bug report, but the other one has an entirely different backtrace so I am not entirely sure.

terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)

The crash can be reproduced every time.

-- Backtrace:
Application: Konsole (konsole), signal: Aborted

[KCrash Handler]
#4  0x00007fb8650a08ec in ?? () from /usr/lib/libc.so.6
#5  0x00007fb865051ea8 in raise () from /usr/lib/libc.so.6
#6  0x00007fb86503b53d in abort () from /usr/lib/libc.so.6
#7  0x00007fb86529a833 in __gnu_cxx::__verbose_terminate_handler () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#8  0x00007fb8652a6d0c in __cxxabiv1::__terminate (handler=<optimized out>) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#9  0x00007fb8652a6d79 in std::terminate () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#10 0x00007fb8652a6fdd in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x7fb86542a148 <typeinfo for std::out_of_range>, dest=0x7fb8652be720 <std::out_of_range::~out_of_range()>) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_throw.cc:98
#11 0x00007fb86529d55b in std::__throw_out_of_range_fmt (__fmt=__fmt@entry=0x7fb866e4fdd0 "vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)") at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/functexcept.cc:101
#12 0x00007fb866d74949 in std::vector<QVector<Konsole::Character>, std::allocator<QVector<Konsole::Character> > >::_M_range_check (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/12.2.1/bits/stl_vector.h:1153
#13 std::vector<QVector<Konsole::Character>, std::allocator<QVector<Konsole::Character> > >::at (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/12.2.1/bits/stl_vector.h:1175
#14 Konsole::Screen::fastAddHistLine (this=0x563d289c6890) at /usr/src/debug/konsole/konsole-22.12.3/src/Screen.cpp:2211
#15 0x00007fb866d6eff4 in Konsole::Screen::resizeImage (this=0x563d289c6890, new_lines=35, new_columns=109) at /usr/src/debug/konsole/konsole-22.12.3/src/Screen.cpp:609
#16 0x00007fb866d65db0 in Konsole::Emulation::setImageSize (this=0x563d28c6ee00, lines=35, columns=109) at /usr/src/debug/konsole/konsole-22.12.3/src/Emulation.cpp:310
#17 0x00007fb8658bea71 in ?? () from /usr/lib/libQt5Core.so.5
#18 0x00007fb866d533cd in Konsole::TerminalDisplay::changedContentSizeSignal (this=<optimized out>, _t1=<optimized out>, _t2=<optimized out>) at /usr/src/debug/konsole/build/src/konsoleprivate_autogen/DRAQINE3W2/moc_TerminalDisplay.cpp:391
#19 0x00007fb866dccaae in Konsole::TerminalDisplay::updateImageSize (this=this@entry=0x563d286712c0) at /usr/src/debug/konsole/konsole-22.12.3/src/terminalDisplay/TerminalDisplay.cpp:973
#20 0x00007fb866dce401 in Konsole::TerminalDisplay::resizeEvent (this=0x563d286712c0, event=<optimized out>) at /usr/src/debug/konsole/konsole-22.12.3/src/terminalDisplay/TerminalDisplay.cpp:928
#21 0x00007fb8665af4d4 in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
#22 0x00007fb866578b5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#23 0x00007fb86588df48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#24 0x00007fb8665ac1b4 in QWidgetPrivate::setGeometry_sys(int, int, int, int, bool) () from /usr/lib/libQt5Widgets.so.5
#25 0x00007fb8665aca8c in QWidget::setGeometry(QRect const&) () from /usr/lib/libQt5Widgets.so.5
#26 0x00007fb86672069a in ?? () from /usr/lib/libQt5Widgets.so.5
#27 0x00007fb866721849 in ?? () from /usr/lib/libQt5Widgets.so.5
#28 0x00007fb8665af4d4 in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
#29 0x00007fb86665da23 in QFrame::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
#30 0x00007fb866578b5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#31 0x00007fb86588df48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#32 0x00007fb8665ac1b4 in QWidgetPrivate::setGeometry_sys(int, int, int, int, bool) () from /usr/lib/libQt5Widgets.so.5
#33 0x00007fb8665aca8c in QWidget::setGeometry(QRect const&) () from /usr/lib/libQt5Widgets.so.5
#34 0x00007fb866591adb in QLayoutPrivate::doResize() () from /usr/lib/libQt5Widgets.so.5
#35 0x00007fb8665929ad in QLayout::activate() () from /usr/lib/libQt5Widgets.so.5
#36 0x00007fb866578bf0 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#37 0x00007fb86588df48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#38 0x00007fb8665ac1b4 in QWidgetPrivate::setGeometry_sys(int, int, int, int, bool) () from /usr/lib/libQt5Widgets.so.5
#39 0x00007fb8665aca8c in QWidget::setGeometry(QRect const&) () from /usr/lib/libQt5Widgets.so.5
#40 0x00007fb866749162 in QTabWidget::setUpLayout(bool) () from /usr/lib/libQt5Widgets.so.5
#41 0x00007fb8665af4d4 in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
#42 0x00007fb866578b5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#43 0x00007fb86588df48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#44 0x00007fb8665ac1b4 in QWidgetPrivate::setGeometry_sys(int, int, int, int, bool) () from /usr/lib/libQt5Widgets.so.5
#45 0x00007fb8665aca8c in QWidget::setGeometry(QRect const&) () from /usr/lib/libQt5Widgets.so.5
#46 0x00007fb8665b8793 in QWidget::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libQt5Widgets.so.5
#47 0x00007fb86674c48c in QTabWidget::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libQt5Widgets.so.5
#48 0x00007fb866d5e82a in Konsole::TabbedViewContainer::qt_metacall (this=0x563d283ecbd0, _c=QMetaObject::WriteProperty, _id=<optimized out>, _a=0x7ffd5d8ce690) at /usr/src/debug/konsole/build/src/konsoleprivate_autogen/IMAN36LHMA/moc_ViewContainer.cpp:260
#49 0x00007fb8656d0805 in QPropertyAnimation::updateCurrentValue(QVariant const&) () from /usr/lib/libQt5Core.so.5
#50 0x00007fb8656d3256 in ?? () from /usr/lib/libQt5Core.so.5
#51 0x00007fb8656d4ea0 in QPropertyAnimation::updateState(QAbstractAnimation::State, QAbstractAnimation::State) () from /usr/lib/libQt5Core.so.5
#52 0x00007fb8656d0127 in ?? () from /usr/lib/libQt5Core.so.5
#53 0x00007fb86665e4ba in ?? () from /usr/lib/libQt5Widgets.so.5
#54 0x00007fb86669f198 in ?? () from /usr/lib/libQt5Widgets.so.5
#55 0x00007fb8666d5656 in ?? () from /usr/lib/libQt5Widgets.so.5
#56 0x00007fb866591adb in QLayoutPrivate::doResize() () from /usr/lib/libQt5Widgets.so.5
#57 0x00007fb866578bf0 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#58 0x00007fb86588df48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#59 0x00007fb8665d030b in ?? () from /usr/lib/libQt5Widgets.so.5
#60 0x00007fb866578b5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#61 0x00007fb86588df48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#62 0x00007fb865d40206 in QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent*) () from /usr/lib/libQt5Gui.so.5
#63 0x00007fb865d28885 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Gui.so.5
#64 0x00007fb85f4e68d0 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#65 0x00007fb863bb882b in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#66 0x00007fb863c0fcc9 in ?? () from /usr/lib/libglib-2.0.so.0
#67 0x00007fb863bb70e2 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#68 0x00007fb8658d8c6c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#69 0x00007fb8658866ec in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#70 0x00007fb865891219 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
#71 0x0000563d265c3b65 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/konsole/konsole-22.12.3/src/main.cpp:252
[Inferior 1 (process 34151) detached]

The reporter indicates this bug may be a duplicate of or related to bug 459722.

Reported using DrKonqi
Comment 1 Matan Ziv-Av 2023-03-05 14:45:31 UTC
*** Bug 459722 has been marked as a duplicate of this bug. ***
Comment 2 Matan Ziv-Av 2023-03-05 14:46:06 UTC
*** Bug 466825 has been marked as a duplicate of this bug. ***
Comment 3 Matan Ziv-Av 2023-03-06 23:37:26 UTC
Git commit a206396862261af8598fa509d20cdc579da89de1 by Matan Ziv-Av.
Committed on 06/03/2023 at 22:54.
Pushed by hindenburg into branch 'master'.

Do not use _lineProperties.at(line) where line might be too large

Use an access function that returns a default line property when
the line may be outside the screen.

M  +12   -5    src/Screen.cpp
M  +1    -0    src/Screen.h

https://invent.kde.org/utilities/konsole/commit/a206396862261af8598fa509d20cdc579da89de1