Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rare crash on showing context menu of notification area item #1802

Open
tsujan opened this issue Jul 27, 2022 · 7 comments · May be fixed by lxqt/libdbusmenu-lxqt#17
Open

Rare crash on showing context menu of notification area item #1802

tsujan opened this issue Jul 27, 2022 · 7 comments · May be fixed by lxqt/libdbusmenu-lxqt#17
Labels

Comments

@tsujan
Copy link
Member

tsujan commented Jul 27, 2022

On rare occasions, for which only the single example of nm-applet --indicator is found until now, lxqt-panel may crash on showing the context menu inside the notification area.

nm-applet's original menu is problematic (→ https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/502), and the cause of the crash is in Qt, not in lxqt-panel:

#0  0x00007fd52eb12ba4 in  () at /usr/lib/libQt5Widgets.so.5
lxqt/lxqt-notificationd#1  0x00007fd52eb17d06 in QMenu::internalDelayedPopup() () at /usr/lib/libQt5Widgets.so.5
lxqt/lxqt-notificationd#2  0x00007fd52deee07f in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
lxqt/lxqt-notificationd#3  0x00007fd52e994762 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
lxqt/lxqt-notificationd#4  0x00007fd52dec163a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
lxqt/lxqt-notificationd#5  0x00007fd52df194c5 in QTimerInfoList::activateTimers() () at /usr/lib/libQt5Core.so.5
lxqt/lxqt-notificationd#6  0x00007fd52df19d72 in  () at /usr/lib/libQt5Core.so.5
lxqt/lxqt-notificationd#7  0x00007fd52d6cd02c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
lxqt/lxqt-notificationd#8  0x00007fd52d720b59 in  () at /usr/lib/libglib-2.0.so.0
lxqt/lxqt-notificationd#9  0x00007fd52d6ca781 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
lxqt/lxqt-notificationd#10 0x00007fd52df1a141 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/libQt5Core.so.5
lxqt/lxqt-notificationd#11 0x00007fd52debff9c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
lxqt/lxqt-notificationd#12 0x00007fd52dec8454 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
lxqt/lxqt-notificationd#13 0x00005595dbbd40b7 in  ()
lxqt/lxqt-notificationd#14 0x00007fd52d888b25 in __libc_start_main () at /usr/lib/libc.so.6
lxqt/lxqt-notificationd#15 0x00005595dbbd468e in _start ()

Apparently, the crash happens in the private slot QMenu::internalDelayedPopup().

I opened this issue in the hope that a workaround might be found.

System Information
  • Latest git LXQt
@tsujan tsujan added the Qt bug label Jul 27, 2022
@tsujan tsujan transferred this issue from lxqt/lxqt-notificationd Jul 27, 2022
@tsujan tsujan changed the title Rare crash on showing context menu Rare crash on showing context menu of notification area item Jul 27, 2022
@tsujan
Copy link
Member Author

tsujan commented Jul 27, 2022

May be somehow related to https://bugreports.qt.io/browse/QTBUG-77273

@stefonarch
Copy link
Member

Still an issue?

@tsujan
Copy link
Member Author

tsujan commented Mar 16, 2024

Still an issue?

I haven't checked, but since the Qt bug report is still unresolved, the issue should still exist. Fortunately, it's very rare.

I wonder if a workaround is possible in libdbusmenu-lxqt.

@tsujan
Copy link
Member Author

tsujan commented Apr 23, 2024

I can't reproduce the issue with Qt6 lxqt-panel + the latest nm-applet + Wayland (labwc). I think something has changed in nm-applet.

Since it wasn't our bug, closing...

@tsujan tsujan closed this as completed Apr 23, 2024
@tsujan
Copy link
Member Author

tsujan commented May 22, 2024

It happened again with nm-applet --indicator but with a different backtrace for Qt6:

#0  0x00007f31c1b010c8 in QAction::isSeparator() const () at /usr/lib/libQt6Gui.so.6
#1  0x00007f31c22c275c in ??? () at /usr/lib/libQt6Widgets.so.6
#2  0x00007f31c22cb132 in QMenu::timerEvent(QTimerEvent*) () at /usr/lib/libQt6Widgets.so.6
#3  0x00007f31c118c0e6 in QObject::event(QEvent*) () at /usr/lib/libQt6Core.so.6
#4  0x00007f31c20fc44d in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt6Widgets.so.6
#5  0x00007f31c113fe18 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt6Core.so.6
#6  0x00007f31c12b7988 in QTimerInfoList::activateTimers() () at /usr/lib/libQt6Core.so.6
#7  0x00007f31c13957c9 in ??? () at /usr/lib/libQt6Core.so.6
#8  0x00007f31c0f0ea89 in ??? () at /usr/lib/libglib-2.0.so.0
#9  0x00007f31c0f709b7 in ??? () at /usr/lib/libglib-2.0.so.0
#10 0x00007f31c0f0df95 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#11 0x00007f31c1393389 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/libQt6Core.so.6
#12 0x00007f31c1148350 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt6Core.so.6
#13 0x00007f31c1143c1d in QCoreApplication::exec() () at /usr/lib/libQt6Core.so.6
#14 0x0000562c3bbfe2ea in ??? ()
#15 0x00007f31c0a39c88 in ??? () at /usr/lib/libc.so.6
#16 0x00007f31c0a39d4c in __libc_start_main () at /usr/lib/libc.so.6
#17 0x0000562c3bbfeb75 in _start ()

EDIT: This time it happened under LXQt+LabWC. Qt's version is 6.7.0.

@tsujan tsujan reopened this May 22, 2024
@tsujan
Copy link
Member Author

tsujan commented May 22, 2024

Sorry, I reopened it by mistake. Still not our bug.

@tsujan tsujan closed this as completed May 22, 2024
@tsujan
Copy link
Member Author

tsujan commented Nov 9, 2024

I think I've found a workaround for this Qt bug, which persists in Qt6. I'll make a PR against libdbusmenu-lxqt if I can't reproduce the crash with the workaround for a day or two (the crash was very easy to reproduce with nm-applet).

Reopening...

EDIT: After I wrestled with it for many hours, it crashed again. I really tried many ways — even borrowed KDE codes —to no avail.

EDIT2: Found an effective workaround at last.

@tsujan tsujan reopened this Nov 9, 2024
tsujan added a commit to lxqt/libdbusmenu-lxqt that referenced this issue Nov 15, 2024
Such random crashes are triggered by Qt → `QMenu::timerEvent()`. Qt doesn't take into account the possibility of dangling pointers in `qmenu.cpp` under very rare circumstances, e.g., when the actions of a menu with a visible submenu are recreated too rapidly multiple times (also see https://bugreports.qt.io/browse/QTBUG-77273, although our case is much more complex). That may no be unexpected in a code full of timers and event handling.

To avoid dangling pointers, the patch just puts a minimum interval of two seconds between two consecutive reloads.

It also restores the active action on refreshing, such that a reloaded submenu isn't closed anymore (see lxqt/lxqt#2282 and especially @yan12125's report https://gitlab.gnome.org/GNOME/network-manager-applet/-/issues/195).

Finally, it removes a redundant, recursive computation.

Closes lxqt/lxqt-panel#1802

NOTE: I was able to reproduce the crash easily with nm-applet. Before arriving at this workaround, I tried various ideas but could still make lxqt-panel crash in a few minutes. Only this time I can't, in spite of trying for days.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants