Bug 419526 - Qt5.15 Crash on right click
Summary: Qt5.15 Crash on right click
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 20.03.80
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-02 08:15 UTC by Antonio Rojas
Modified: 2020-06-01 16:17 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.04.2


Attachments
konsole-20200425-001339.kcrash.txt (16.73 KB, text/plain)
2020-04-24 22:18 UTC, Andreas Sturmlechner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Rojas 2020-04-02 08:15:26 UTC
SUMMARY
konsole and yakuake 20.04 beta crash very frequently when right-clicking on the terminal. Using Qt 5.15 beta, in case it's relevant

(gdb) bt
#0  QMenuSloppyState::setSubMenuPopup (this=0x555555ac7380, actionRect=..., resetAction=0x0, subMenu=0x0) at widgets/qmenu.cpp:795
#1  0x00007ffff7168317 in QMenu::internalDelayedPopup (this=this@entry=0x555555ad0c10) at /usr/include/c++/9.3.0/bits/atomic_base.h:413
#2  0x00007ffff716e9b6 in QMenu::timerEvent (this=0x555555ad0c10, e=<optimized out>) at widgets/qmenu.cpp:3503
#3  0x00007ffff64ba8f9 in QObject::event (this=this@entry=0x555555ad0c10, e=e@entry=0x7fffffffd080) at kernel/qobject.cpp:1291
#4  0x00007ffff6ff8ae9 in QWidget::event (this=this@entry=0x555555ad0c10, event=event@entry=0x7fffffffd080) at kernel/qwidget.cpp:9089
#5  0x00007ffff716e64d in QMenu::event (this=0x555555ad0c10, e=0x7fffffffd080) at widgets/qmenu.cpp:3049
#6  0x00007ffff6fac164 in QApplicationPrivate::notify_helper (this=this@entry=0x555555576140, receiver=receiver@entry=0x555555ad0c10, 
    e=e@entry=0x7fffffffd080) at kernel/qapplication.cpp:3673
#7  0x00007ffff6fb6ee0 in QApplication::notify (this=0x5555555758c0, receiver=0x555555ad0c10, e=0x7fffffffd080) at kernel/qapplication.cpp:3623
#8  0x00007ffff6480e0f in QCoreApplication::notifyInternal2 (receiver=0x555555ad0c10, event=0x7fffffffd080) at kernel/qcoreapplication.cpp:1061
#9  0x00007ffff6481024 in QCoreApplication::sendEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1456
#10 0x00007ffff64ec29c in QTimerInfoList::activateTimers (this=0x5555555f06e0) at kernel/qtimerinfo_unix.cpp:643
#11 0x00007ffff64ecade in timerSourceDispatch (source=<optimized out>) at kernel/qeventdispatcher_glib.cpp:183
#12 0x00007ffff2b6d9be in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#13 0x00007ffff2b6f831 in ?? () from /usr/lib/libglib-2.0.so.0
#14 0x00007ffff2b6f871 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#15 0x00007ffff64ece78 in QEventDispatcherGlib::processEvents (this=0x5555555d8da0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#16 0x00007ffff10c7866 in QXcbGlibEventDispatcher::processEvents (this=<optimized out>, flags=...) at qxcbeventdispatcher.cpp:143
#17 0x00007ffff647e971 in QEventLoop::processEvents (this=this@entry=0x7fffffffd2e0, flags=..., flags@entry=...)
    at /usr/include/c++/9.3.0/bits/atomic_base.h:734
#18 0x00007ffff647edba in QEventLoop::exec (this=this@entry=0x7fffffffd2e0, flags=flags@entry=...)
    at ../../include/QtCore/../../src/corelib/global/qflags.h:125
#19 0x00007ffff7167a2f in QMenuPrivate::exec(QPoint const&, QAction*, std::function<QPoint (QSize const&)>) (this=0x555555ac7120, p=..., 
    action=action@entry=0x0, positionFunction=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#20 0x00007ffff7167c96 in QMenu::exec (this=this@entry=0x555555ad0c10, p=..., action=action@entry=0x0) at /usr/include/c++/9.3.0/bits/std_function.h:396
#21 0x00007ffff7cc72e4 in Konsole::SessionController::showDisplayContextMenu (this=0x5555556bd460, position=...)
    at /usr/include/c++/9.3.0/bits/atomic_base.h:413
--Type <RET> for more, q to quit, c to continue without paging--
#22 0x00007ffff64c2ece in QtPrivate::QSlotObjectBase::call (a=0x7fffffffd550, r=0x5555556bd460, this=0x555555ab2bd0)
    at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#23 doActivate<false> (sender=<optimized out>, signal_index=<optimized out>, argv=<optimized out>, argv@entry=0x7fffffffd550) at kernel/qobject.cpp:3886
#24 0x00007ffff64b9ee4 in QMetaObject::activate (sender=sender@entry=0x555555a3e9c0, 
    m=m@entry=0x7ffff7d4dec0 <Konsole::TerminalDisplay::staticMetaObject>, local_signal_index=local_signal_index@entry=5, argv=argv@entry=0x7fffffffd550)
    at kernel/qobject.cpp:3946
#25 0x00007ffff7c3ad36 in Konsole::TerminalDisplay::configureRequest (this=this@entry=0x555555a3e9c0, _t1=...)
    at /usr/src/debug/build/src/konsoleprivate_autogen/EWIEGA46WW/moc_TerminalDisplay.cpp:463
#26 0x00007ffff7ce4881 in Konsole::TerminalDisplay::mousePressEvent (this=0x555555a3e9c0, ev=0x7fffffffda80) at /usr/include/qt/QtGui/qevent.h:121
#27 0x00007ffff6ff7be3 in QWidget::event (this=0x555555a3e9c0, event=0x7fffffffda80) at kernel/qwidget.cpp:8650
#28 0x00007ffff6fac164 in QApplicationPrivate::notify_helper (this=this@entry=0x555555576140, receiver=receiver@entry=0x555555a3e9c0, e=0x7fffffffda80)
    at kernel/qapplication.cpp:3673
#29 0x00007ffff6fb5525 in QApplication::notify (this=<optimized out>, receiver=0x555555a3e9c0, e=0x7fffffffda80) at kernel/qapplication.cpp:3117
#30 0x00007ffff6480e0f in QCoreApplication::notifyInternal2 (receiver=0x555555a3e9c0, event=0x7fffffffda80) at kernel/qcoreapplication.cpp:1061
#31 0x00007ffff6481042 in QCoreApplication::sendSpontaneousEvent (receiver=receiver@entry=0x555555a3e9c0, event=event@entry=0x7fffffffda80)
    at kernel/qcoreapplication.cpp:1468
#32 0x00007ffff6fb426c in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x555555a3e9c0, event=event@entry=0x7fffffffda80, 
    alienWidget=alienWidget@entry=0x555555a3e9c0, nativeWidget=0x55555568d560, buttonDown=buttonDown@entry=0x7ffff757fa30 <qt_button_down>, 
    lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2603
#33 0x00007ffff7014e4b in QWidgetWindow::handleMouseEvent (this=this@entry=0x55555569f6b0, event=event@entry=0x7fffffffdec0)
    at /usr/include/c++/9.3.0/bits/atomic_base.h:413
#34 0x00007ffff7018971 in QWidgetWindow::event (this=0x55555569f6b0, event=0x7fffffffdec0) at kernel/qwidgetwindow.cpp:295
#35 0x00007ffff6fac164 in QApplicationPrivate::notify_helper (this=this@entry=0x555555576140, receiver=receiver@entry=0x55555569f6b0, 
    e=e@entry=0x7fffffffdec0) at kernel/qapplication.cpp:3673
#36 0x00007ffff6fb51d6 in QApplication::notify (this=0x5555555758c0, receiver=0x55555569f6b0, e=0x7fffffffdec0) at kernel/qapplication.cpp:3013
#37 0x00007ffff6480e0f in QCoreApplication::notifyInternal2 (receiver=0x55555569f6b0, event=0x7fffffffdec0) at kernel/qcoreapplication.cpp:1061
#38 0x00007ffff6481042 in QCoreApplication::sendSpontaneousEvent (receiver=receiver@entry=0x55555569f6b0, event=event@entry=0x7fffffffdec0)
--Type <RET> for more, q to quit, c to continue without paging--
    at kernel/qcoreapplication.cpp:1468
#39 0x00007ffff6881e8e in QGuiApplicationPrivate::processMouseEvent (e=e@entry=0x7fffe0019810) at kernel/qguiapplication.cpp:2211
#40 0x00007ffff68832f8 in QGuiApplicationPrivate::processWindowSystemEvent (e=e@entry=0x7fffe0019810) at kernel/qguiapplication.cpp:1943
#41 0x00007ffff685550a in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1172
#42 0x00007ffff10c7503 in xcbSourceDispatch (source=<optimized out>) at qxcbeventdispatcher.cpp:105
#43 0x00007ffff2b6d9be in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#44 0x00007ffff2b6f831 in ?? () from /usr/lib/libglib-2.0.so.0
#45 0x00007ffff2b6f871 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#46 0x00007ffff64ece78 in QEventDispatcherGlib::processEvents (this=0x5555555d8da0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#47 0x00007ffff10c7866 in QXcbGlibEventDispatcher::processEvents (this=<optimized out>, flags=...) at qxcbeventdispatcher.cpp:143
#48 0x00007ffff647e971 in QEventLoop::processEvents (this=this@entry=0x7fffffffe260, flags=..., flags@entry=...)
    at /usr/include/c++/9.3.0/bits/atomic_base.h:734
#49 0x00007ffff647edba in QEventLoop::exec (this=this@entry=0x7fffffffe260, flags=flags@entry=...)
    at ../../include/QtCore/../../src/corelib/global/qflags.h:125
#50 0x00007ffff648977e in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#51 0x00007ffff68748ca in QGuiApplication::exec () at kernel/qguiapplication.cpp:1864
#52 0x00007ffff6fac0d9 in QApplication::exec () at kernel/qapplication.cpp:2813
#53 0x00007ffff7f4e3d4 in kdemain (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/konsole-20.03.80/src/main.cpp:229
#54 0x00007ffff7d80023 in __libc_start_main () from /usr/lib/libc.so.6
#55 0x000055555555505e in _start ()
Comment 1 Andreas Sturmlechner 2020-04-24 22:18:06 UTC
Created attachment 127842 [details]
konsole-20200425-001339.kcrash.txt

Yes, same here with 20.04.0. Attaching backtrace with debug symbols.

Operating System: Gentoo 
KDE Plasma Version: 5.18.4
KDE Frameworks Version: 5.69.0
Qt Version: 5.15.0
Kernel Version: 5.6.5-gentoo
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-4790K CPU @ 4.00GHz
Memory: 15.4 GiB of RAM
Comment 2 Andreas Sturmlechner 2020-04-24 22:44:03 UTC
To be precise, it crashes exactly when hovering over "Set Encoding", before it manages to pop up the submenu. It does not do the same with "Switch Profile".
Comment 3 Kurt Hindenburg 2020-04-27 02:59:22 UTC
Any chance you can try on < Qt5.15?  It would be nice to confirm it is something new in Qt5.15.
Comment 4 Antonio Rojas 2020-04-27 18:33:35 UTC
yes, this is Qt5.15 specific
Comment 5 Andreas Sturmlechner 2020-04-28 08:16:17 UTC
(In reply to Antonio Rojas from comment #4)
> yes, this is Qt5.15 specific

Yes indeed.
Comment 7 Fabian Vogt 2020-05-27 09:01:35 UTC
The issue seems to be:

connect(_codecAction->menu(), &QMenu::aboutToShow, this, &Konsole::SessionController::updateCodecAction);

void SessionController::updateCodecAction()
{
    _codecAction->setCurrentCodec(QString::fromUtf8(_session->codec()));
}

bool KCodecAction::setCurrentCodec(QTextCodec *codec)
{
  ...
                if (codec == KCharsets::charsets()->codecForName(actions().at(i)->menu()->actions().at(j)->text())) {
                    d->currentSubAction = actions().at(i)->menu()->actions().at(j);
                    d->currentSubAction->trigger();
                    return true;
                }
  ...
}

So the aboutToShow signal hides the menu directly, leading to a null deref later on.

It should probably use ->setChecked(true); instead.
Comment 8 Kurt Hindenburg 2020-05-28 12:51:01 UTC
So this is a KCodecAction issue?  Have you tried using other apps that have a codec menu to see if they all crash.
Comment 9 Fabian Vogt 2020-05-28 12:58:36 UTC
(In reply to Kurt Hindenburg from comment #8)
> So this is a KCodecAction issue?

I changed KCodecAction to use setChecked(true); throughout and it did fully fix the crash. It doesn't have the same behaviour though, the parent QAction doesn't get checked automatically.

> Have you tried using other apps that have a codec menu to see if they all crash.

I tried it in KMail and it does not crash. Most likely it does not call setCurrentCodec in aboutToShow.
Comment 10 Ahmad Samir 2020-05-28 19:54:26 UTC
Proposed fix https://invent.kde.org/utilities/konsole/-/merge_requests/103
Comment 11 Kurt Hindenburg 2020-05-29 11:51:32 UTC
Git commit e7e8e9d1a9b129d73a4c502af873fb01fb2795fb by Kurt Hindenburg, on behalf of Ahmad Samir.
Committed on 29/05/2020 at 11:43.
Pushed by hindenburg into branch 'master'.

[SessionController] Fix crash caused by text encoding menu

QMenu since 5.15 is hidden when an action is triggered, this caused a
crash in Konsole when trying to access the text encoding menu.

Now Session emits a signal when the text encoding is changed, the
SessionController can connect to that singal to set the current codec in
the KCodecAction object.

Also fix the EditProfileDialog so that when the KCodecAction menu is
shown the currently set codec is selected.

FIXED-IN: 20.08

M  +1    -0    src/EditProfileDialog.cpp
M  +2    -0    src/Session.cpp
M  +5    -0    src/Session.h
M  +4    -3    src/SessionController.cpp
M  +1    -1    src/SessionController.h

https://invent.kde.org/utilities/konsole/commit/e7e8e9d1a9b129d73a4c502af873fb01fb2795fb
Comment 12 Kurt Hindenburg 2020-05-29 12:06:41 UTC
Git commit 27ee6a27380c91b7e98d9fa09915a9d33ee03ea1 by Kurt Hindenburg, on behalf of Ahmad Samir.
Committed on 29/05/2020 at 12:00.
Pushed by hindenburg into branch 'release/20.04'.

[SessionController] Fix crash caused by text encoding menu

QMenu since 5.15 is hidden when an action is triggered, this caused a
crash in Konsole when trying to access the text encoding menu.

Now Session emits a signal when the text encoding is changed, the
SessionController can connect to that singal to set the current codec in
the KCodecAction object.

Also fix the EditProfileDialog so that when the KCodecAction menu is
shown the currently set codec is selected.

FIXED-IN: 20.08
(cherry picked from commit e7e8e9d1a9b129d73a4c502af873fb01fb2795fb)

M  +1    -0    src/EditProfileDialog.cpp
M  +2    -0    src/Session.cpp
M  +5    -0    src/Session.h
M  +4    -3    src/SessionController.cpp
M  +1    -1    src/SessionController.h

https://invent.kde.org/utilities/konsole/commit/27ee6a27380c91b7e98d9fa09915a9d33ee03ea1
Comment 13 Ahmad Samir 2020-06-01 15:14:57 UTC
@Fabian: I am sorry, I forgot to credit you in the commit message, you basically pin-pointed the responsible code in Konsole.
Comment 14 Fabian Vogt 2020-06-01 16:17:55 UTC
(In reply to Ahmad Samir from comment #13)
> @Fabian: I am sorry, I forgot to credit you in the commit message, you
> basically pin-pointed the responsible code in Konsole.

No worries. What counts is that the bug is fixed!