Bug 447358

Summary: App crash when displaying tooltip on tray icon
Product: [Frameworks and Libraries] frameworks-kxmlgui Reporter: Juraj <jurajoravec>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 5.89.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Juraj 2021-12-21 19:45:09 UTC
SUMMARY
The application crashes when the tooltip should be displayed over the old styled tray icon (tint2 panel).
I tested it on Kmail and in the past on some other kde program.
Possibly related to https://bugs.kde.org/show_bug.cgi?id=442352


STEPS TO REPRODUCE
1. Start kmail with tray icon enabled
2. Do with mouse over the tray icon
3. Wait for tooltip to show

OBSERVED RESULT
Crash

EXPECTED RESULT
Display tooltip.

SOFTWARE/OS VERSIONS
KDE version are latest from git at the moment of posting. (could not quickly build kinfocenter.)
Qt Version: 5.15.2+kde+r263-6

ADDITIONAL INFORMATION
I tracked this issue to the kxmlgui through the bacjtrace, there is aposibility that it is bug in Qt.

BACKTRACE
#0  0x00007fffed714a55 in QWidget::toolTip() const () at /usr/lib/libQt5Widgets.so.5
#1  0x00007fffeed61cd1 in KToolTipHelperPrivate::handleToolTipEvent(QWidget*, QHelpEvent*) (this=0x555555cde4a0, watchedWidget=0x7fff740364f0, helpEvent=0x7fffffffd900)
    at /home/juraj/kde/src/kxmlgui/src/ktooltiphelper.cpp:216
#2  0x00007fffeed610b9 in KToolTipHelperPrivate::eventFilter(QObject*, QEvent*) (this=0x555555cde4a0, watched=0x7fff740364f0, event=0x7fffffffd900)
    at /home/juraj/kde/src/kxmlgui/src/ktooltiphelper.cpp:72
#3  0x00007fffeed61033 in KToolTipHelper::eventFilter(QObject*, QEvent*) (this=0x555555cde420, watched=0x7fff740364f0, event=0x7fffffffd900)
    at /home/juraj/kde/src/kxmlgui/src/ktooltiphelper.cpp:61
#4  0x00007fffec9c5dde in QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#5  0x00007fffed6e6032 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#6  0x00007fffec9c61ba in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#7  0x00007fffedaab5dc in  () at /usr/lib/libQt5Widgets.so.5
#8  0x00007fffed6e5ff6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#9  0x00007fffed6eed33 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#10 0x00007fffec9c61ba in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#11 0x00007fffed6ebc6c in QApplication::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#12 0x00007fffed6e5ff6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#13 0x00007fffec9c61ba in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#14 0x00007fffeca1edbd in QTimerInfoList::activateTimers() () at /usr/lib/libQt5Core.so.5
#15 0x00007fffeca1f6fa in  () at /usr/lib/libQt5Core.so.5
#16 0x00007fffe74980ec in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#17 0x00007fffe74ed889 in  () at /usr/lib/libglib-2.0.so.0
#18 0x00007fffe7495735 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#19 0x00007fffeca1fada in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#20 0x00007fffec9c4a6b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#21 0x00007fffec9cd258 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#22 0x0000555555559975 in main(int, char**) (argc=1, argv=0x7fffffffdf88) at /home/juraj/kde/src/kmail/src/main.cpp:175
Comment 1 Juraj 2022-06-21 00:32:34 UTC
After another round of debugging I found that the crash is caused in the check code:

>    while (m_widget->toolTip().isEmpty()) {
>        m_widget = m_widget->parentWidget();
>        if (!m_widget) {
>            return false;
>        }
>    }
>    if (m_widget->whatsThis().isEmpty()) {
>        if (m_widget->toolTip() == whatsThisHintOnly()) {
>            return true;
>        }
>        return false;
>    }

And the crash is triggered on both `m_widget->toolTip()` and `m_widget->whatsThis()` calls.
If I comment one half the other will crash.
If I comment both the tooltip will be shown and there will be no crash.

Somehow calling either toolTip() or whatsThis() is bad and crashes the program but when the toolTip() is called as the parameter of the function showExpandableToolTip everything is fine and programs is happy.

These results were obtained by compiling the code with kdesrc-build and as test program for tray icon I used akregator.

My setup is OpenBox with tint2 panel/tray.

The version of this file before this change is working fine.
Working commit: ecd7cefd
Crashing commit (and later): 84682615
Comment 2 Juraj 2022-09-23 20:41:50 UTC
This bug was fixed by commit:
https://invent.kde.org/frameworks/kxmlgui/-/commit/59affd7d0fea0ec69c7b0d75bab08510b7c00359

At least it now works for me.