summaryrefslogtreecommitdiffstats
path: root/src/gui/platform/unix/qdesktopunixservices.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-03-25 16:16:44 +0100
committerMarc Mutz <marc.mutz@qt.io>2025-03-28 07:55:38 +0100
commit83af06b0e5d1ca3aa348debd39f88dfbdbf117b8 (patch)
treee9438ccf40b73035891fd371d7aaed3f860f61d0 /src/gui/platform/unix/qdesktopunixservices.cpp
parentc0dbfe6c8776fb2f8ca1d7051a605329a9764b83 (diff)
tst_QMenuBar: avoid UB (invalid downcast) in allowActiveAndDisabled()
When the test functions runs off the end (or returns from a failed QCOMPARE/QVERIFY), `activeMenu` is destroyed while it's the QMenuBarPrivate::activeMenu, and the following focusInEvent() on the QMenuBar causes QMenuBarPrivate::setCurrentAction() to access `activeMenu` when it has already ceased to be a QMenu. Says UBSan: qpointer.h:75:14: runtime error: downcast of address 0x7fff87934860 which does not point to an object of type 'QMenu' 0x7fff87934860: note: object is of type 'QWidget' 00 00 00 00 08 f1 0e be 17 7f 00 00 80 c8 00 00 90 61 00 00 b8 f2 0e be 17 7f 00 00 00 00 62 c6 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QWidget' #0 0x7f17baf57be5 in QPointer<QMenu>::data() const qpointer.h:75 #1 0x7f17baf57be5 in QPointer<QMenu>::operator QMenu*() const qpointer.h:83 #2 0x7f17baf57be5 in QMenuBarPrivate::setCurrentAction(QAction*, bool, bool) qmenubar.cpp:351 #3 0x7f17baf5a200 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:245 #4 0x7f17baf5b727 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:1260 #5 0x7f17baf5b727 in QMenuBar::focusInEvent(QFocusEvent*) qmenubar.cpp:1259 [...] #34 0x7f17b93373d6 in QWidget::~QWidget() qwidget.cpp:1508 #35 0x7f17badb4658 in QMenu::~QMenu() qmenu.cpp:1789 Since I couldn't fix the problem on short notice, I created QTBUG-135151 to track it. For now, simply close the QMenuBar on all exists from the test function to avoid this code path. Task-number: QTBUG-135151 Pick-to: 6.9 6.8 6.5 Change-Id: Id8c9ee090d8bbc5ec22ce3f2ff7485766640ab43 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/gui/platform/unix/qdesktopunixservices.cpp')
0 files changed, 0 insertions, 0 deletions