Skip to content

Commit

Permalink
browsebox a11y: Use recursive mutex
Browse files Browse the repository at this point in the history
Fixes a deadlock seen for this scenario
with the qt6 VCL plugin on Linux:

1) start Orca
2) Start Base, create a new database
2) With the "Tables" section enabled, click on
   "Create Table in Design View..."
3) click around in the table, use Tab key to move focus

AccessibleBrowseBoxAccess::commitEvent (frame 20 in the below
backtrace) locks the mutex, and then
AccessibleBrowseBoxAccess::getAccessibleContext (frame 8) tries to
acquire the mutex again and deadlocks.

Locking in AccessibleBrowseBoxAccess::commitEvent was added in

    commit 67158da
    Date:   Fri Oct 4 14:22:22 2024 +0100

        cid#1608061 Data race condition

        and

        cid#1607995 Data race condition

Backtrace:

    Thread 1 "soffice.bin" received signal SIGINT, Interrupt.
    futex_wait (futex_word=0x7fffd804ba30, expected=2, private=0) at ../sysdeps/nptl/futex-internal.h:146
    warning: 146    ../sysdeps/nptl/futex-internal.h: No such file or directory
    (gdb) bt
    #0  futex_wait (futex_word=0x7fffd804ba30, expected=2, private=0) at ../sysdeps/nptl/futex-internal.h:146
    #1  __GI___lll_lock_wait (futex=futex@entry=0x7fffd804ba30, private=0) at ./nptl/lowlevellock.c:49
    #2  0x00007ffff789f3a2 in lll_mutex_lock_optimized (mutex=0x7fffd804ba30) at ./nptl/pthread_mutex_lock.c:48
    #3  ___pthread_mutex_lock (mutex=0x7fffd804ba30) at ./nptl/pthread_mutex_lock.c:93
    #4  0x00007fffee0d742f in __gthread_mutex_lock (__mutex=0x7fffd804ba30) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:762
    #5  0x00007fffee0d9915 in std::mutex::lock (this=0x7fffd804ba30) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/std_mutex.h:113
    #6  0x00007fffee0d98e4 in std::unique_lock<std::mutex>::lock (this=0x7fffffff3b48) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_lock.h:147
    #7  0x00007fffee0d8108 in std::unique_lock<std::mutex>::unique_lock (this=0x7fffffff3b48, __m=...) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_lock.h:73
    #8  0x00007fffee0d729d in AccessibleBrowseBoxAccess::getAccessibleContext (this=0x7fffd804ba00) at /home/michi/development/git/libreoffice/vcl/source/accessibility/AccessibleBrowseBox.cxx:281
    #9  0x00007fffee0d7404 in non-virtual thunk to AccessibleBrowseBoxAccess::getAccessibleContext() () at /home/michi/development/git/libreoffice/instdir/program/libvcllo.so
    #10 0x00007fffe42c3b8c in QtAccessibleWidget::getAccessibleContextImpl (this=0x7fffd804b9a0) at vcl/qt6/../qt5/QtAccessibleWidget.cxx:93
    #11 0x00007fffe42c451d in QtAccessibleWidget::childCount (this=0x7fffd804b9a0) at vcl/qt6/../qt5/QtAccessibleWidget.cxx:149
    #12 0x00007fffe290e9d5 in AtSpiAdaptor::notifyAboutCreation (this=0x555556916e10, interface=0x7fffd8051df0) at /home/michi/development/git/qt5/qtbase/src/gui/accessible/linux/atspiadaptor.cpp:1403
    #13 0x00007fffe290ad18 in AtSpiAdaptor::notify (this=0x555556916e10, event=0x7fffffff5e40) at /home/michi/development/git/qt5/qtbase/src/gui/accessible/linux/atspiadaptor.cpp:971
    #14 0x00007fffe2966779 in QSpiAccessibleBridge::notifyAccessibilityUpdate (this=0x5555568aab30, event=0x7fffffff5e40) at /home/michi/development/git/qt5/qtbase/src/gui/accessible/linux/qspiaccessiblebridge.cpp:85
    #15 0x00007fffe28e5c89 in QAccessible::updateAccessibility (event=0x7fffffff5e40) at /home/michi/development/git/qt5/qtbase/src/gui/accessible/qaccessible.cpp:943
    #16 0x00007fffe42bb466 in QtAccessibleEventListener::notifyEvent (this=0x555557d6de30, rEvent=...) at vcl/qt6/../qt5/QtAccessibleEventListener.cxx:231
    #17 0x00007ffff60ec617 in comphelper::AccessibleEventNotifier::addEvent (_nClient=288, _rEvent=...) at /home/michi/development/git/libreoffice/comphelper/source/misc/accessibleeventnotifier.cxx:256
    #18 0x00007ffff60e8107 in comphelper::OCommonAccessibleComponent::NotifyAccessibleEvent (this=0x55555be2f520, _nEventId=7, _rOldValue=uno::Any(void), _rNewValue=uno::Any("com.sun.star.accessibility.XAccessible": ...), nIndexHint=-1)
        at /home/michi/development/git/libreoffice/comphelper/source/misc/accessiblecomponenthelper.cxx:127
    #19 0x00007fffee0dd7c9 in AccessibleBrowseBoxBase::commitEvent (this=0x55555be2f520, _nEventId=7, _rNewValue=uno::Any("com.sun.star.accessibility.XAccessible": ...), _rOldValue=uno::Any(void))
        at /home/michi/development/git/libreoffice/vcl/source/accessibility/AccessibleBrowseBoxBase.cxx:310
    #20 0x00007fffee0d8fb0 in AccessibleBrowseBoxAccess::commitEvent (this=0x7fffd804ba00, nEventId=7, rNewValue=uno::Any("com.sun.star.accessibility.XAccessible": ...), rOldValue=uno::Any(void))
        at vcl/inc/accessibility/AccessibleBrowseBox.hxx:250
    #21 0x00007ffff08806b6 in BrowseBox::commitBrowseBoxEvent (this=0x55555bdc8bf0, _nEventId=7, _rNewValue=uno::Any("com.sun.star.accessibility.XAccessible": ...), _rOldValue=uno::Any(void))
        at /home/michi/development/git/libreoffice/svtools/source/brwbox/brwbox3.cxx:406
    #22 0x00007ffff08a090b in svt::EditBrowseBox::implCreateActiveAccessible (this=0x55555bdc8bf0) at /home/michi/development/git/libreoffice/svtools/source/brwbox/editbrowsebox2.cxx:87
    #23 0x00007ffff089c7af in svt::EditBrowseBox::ActivateCell (this=0x55555bdc8bf0, nRow=0, nCol=1, bCellFocus=true) at /home/michi/development/git/libreoffice/svtools/source/brwbox/editbrowsebox.cxx:945
    #24 0x00007ffff089e6c0 in svt::EditBrowseBox::ActivateCell (this=0x55555bdc8bf0) at include/svtools/editbrowsebox.hxx:1029
    #25 0x00007ffff089b291 in svt::EditBrowseBox::implActivateCellOnMouseEvent (this=0x55555bdc8bf0, _rEvt=..., _bUp=true) at /home/michi/development/git/libreoffice/svtools/source/brwbox/editbrowsebox.cxx:482
    #26 0x00007ffff089b43c in svt::EditBrowseBox::MouseButtonUp (this=0x55555bdc8bf0, rEvt=...) at /home/michi/development/git/libreoffice/svtools/source/brwbox/editbrowsebox.cxx:468
    #27 0x00007ffff08876ad in BrowserDataWin::MouseButtonUp (this=0x555556fed350, rEvt=...) at /home/michi/development/git/libreoffice/svtools/source/brwbox/datwin.cxx:490
    #28 0x00007fffee4b1055 in ImplHandleMouseEvent (xWindow=..., nSVEvent=NotifyEventType::MOUSEBUTTONUP, bMouseLeave=false, nX=73, nY=89, nMsgTime=10536810, nCode=1, nMode=(MouseEventModifiers::SIMPLECLICK | MouseEventModifiers::SELECT))
        at /home/michi/development/git/libreoffice/vcl/source/window/winproc.cxx:719
    #29 0x00007fffee4b5571 in ImplHandleSalMouseButtonUp (pWindow=0x7fffd80482c0, pEvent=0x7fffffff8118) at /home/michi/development/git/libreoffice/vcl/source/window/winproc.cxx:2351
    #30 0x00007fffee4b4280 in ImplWindowFrameProc (_pWindow=0x7fffd80482c0, nEvent=SalEvent::MouseButtonUp, pEvent=0x7fffffff8118) at /home/michi/development/git/libreoffice/vcl/source/window/winproc.cxx:2700
    #31 0x00007fffe435910c in SalFrame::CallCallback (this=0x555556abc050, nEvent=SalEvent::MouseButtonUp, pEvent=0x7fffffff8118) at vcl/inc/salframe.hxx:311
    #32 0x00007fffe43563b5 in QtFrame::CallCallback (this=0x555556abc040, nEvent=SalEvent::MouseButtonUp, pEvent=0x7fffffff8118) at vcl/inc/qt6/../qt5/QtFrame.hxx:235
    #33 0x00007fffe445475a in QtWidget::handleMouseButtonEvent (rFrame=..., pEvent=0x7fffffff93c0) at vcl/qt6/../qt5/QtWidget.cxx:117
    #34 0x00007fffe4454a11 in QtWidget::mouseReleaseEvent (this=0x7fffd8048d90, pEvent=0x7fffffff93c0) at vcl/qt6/../qt5/QtWidget.cxx:128
    #35 0x00007fffe149f8ad in QWidget::event (this=0x7fffd8048d90, event=0x7fffffff93c0) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidget.cpp:8964
    #36 0x00007fffe44569ae in QtWidget::event (this=0x7fffd8048d90, pEvent=0x7fffffff93c0) at vcl/qt6/../qt5/QtWidget.cxx:678
    #37 0x00007fffe13e2e20 in QApplicationPrivate::notify_helper (this=0x555555577ae0, receiver=0x7fffd8048d90, e=0x7fffffff93c0) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3305
    #38 0x00007fffe13e4af2 in QApplication::notify (this=0x555555564d60, receiver=0x7fffd8048d90, e=0x7fffffff93c0) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:2782
    #39 0x00007fffe344b419 in QCoreApplication::notifyInternal2 (receiver=0x7fffd8048d90, event=0x7fffffff93c0) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1112
    #40 0x00007fffe344c119 in QCoreApplication::sendSpontaneousEvent (receiver=0x7fffd8048d90, event=0x7fffffff93c0) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1566
    #41 0x00007fffe13e3747 in QApplicationPrivate::sendMouseEvent
        (receiver=0x7fffd8048d90, event=0x7fffffff93c0, alienWidget=0x7fffd8048d90, nativeWidget=0x555556f2f660, buttonDown=0x7fffe1fca488 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false)
        at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:2363
    #42 0x00007fffe14ded48 in QWidgetWindow::handleMouseEvent (this=0x5555577f5b40, event=0x7fffffffa498) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidgetwindow.cpp:669
    #43 0x00007fffe14dd555 in QWidgetWindow::event (this=0x5555577f5b40, event=0x7fffffffa498) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qwidgetwindow.cpp:292
    #44 0x00007fffe13e2e20 in QApplicationPrivate::notify_helper (this=0x555555577ae0, receiver=0x5555577f5b40, e=0x7fffffffa498) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3305
    #45 0x00007fffe13e6d3d in QApplication::notify (this=0x555555564d60, receiver=0x5555577f5b40, e=0x7fffffffa498) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3255
    #46 0x00007fffe344b419 in QCoreApplication::notifyInternal2 (receiver=0x5555577f5b40, event=0x7fffffffa498) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1112
    #47 0x00007fffe344c119 in QCoreApplication::sendSpontaneousEvent (receiver=0x5555577f5b40, event=0x7fffffffa498) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1566
    #48 0x00007fffe2285ca2 in QGuiApplicationPrivate::processMouseEvent (e=0x7fffd0001560) at /home/michi/development/git/qt5/qtbase/src/gui/kernel/qguiapplication.cpp:2485
    #49 0x00007fffe2284e66 in QGuiApplicationPrivate::processWindowSystemEvent (e=0x7fffd0001560) at /home/michi/development/git/qt5/qtbase/src/gui/kernel/qguiapplication.cpp:2212
    #50 0x00007fffe236d57d in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at /home/michi/development/git/qt5/qtbase/src/gui/kernel/qwindowsysteminterface.cpp:1113
    #51 0x00007fffe236d42e in QWindowSystemInterface::flushWindowSystemEvents (flags=...) at /home/michi/development/git/qt5/qtbase/src/gui/kernel/qwindowsysteminterface.cpp:1082
    #52 0x00007fffdf8b2685 in QtWaylandClient::QWaylandDisplay::flushRequests (this=0x5555555c8390) at /home/michi/development/git/qt5/qtwayland/src/client/qwaylanddisplay.cpp:526
    #53 0x00007fffdf8ce4e5 in QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtWaylandClient::QWaylandDisplay::*)()>::call(void (QtWaylandClient::QWaylandDisplay::*)(), QtWaylandClient::QWaylandDisplay*, void**)::{lambda()#1}::operator()() const (this=0x7fffffffa9a0) at qtbase/src/corelib/kernel/qobjectdefs_impl.h:127
    #54 0x00007fffdf8ce40d in QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtWaylandClient::QWaylandDisplay::*)()>::call(void (QtWaylandClient::QWaylandDisplay::*)(), QtWaylandClient::QWaylandDisplay*, void**)::{lambda()#1}>(void**, QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtWaylandClient::QWaylandDisplay::*)()>::call(void (QtWaylandClient::QWaylandDisplay::*)(), QtWaylandClient::QWaylandDisplay*, void**)::{lambda()#1}&&) (args=0x7fffd0002f98, fn=...) at qtbase/src/corelib/kernel/qobjectdefs_impl.h:65
    #55 0x00007fffdf8ce32f in QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtWaylandClient::QWaylandDisplay::*)()>::call(void (QtWaylandClient::QWaylandDisplay::*)(), QtWaylandClient::QWaylandDisplay*, void**) (f=(void (QtWaylandClient::QWaylandDisplay::*)(class QtWaylandClient::QWaylandDisplay * const)) 0x7fffdf8b2640 <QtWaylandClient::QWaylandDisplay::flushRequests()>, o=0x5555555c8390, arg=0x7fffd0002f98)
        at qtbase/src/corelib/kernel/qobjectdefs_impl.h:126
    #56 0x00007fffdf8ce2a1 in QtPrivate::FunctionPointer<void (QtWaylandClient::QWaylandDisplay::*)()>::call<QtPrivate::List<>, void>(void (QtWaylandClient::QWaylandDisplay::*)(), QtWaylandClient::QWaylandDisplay*, void**)
        (f=(void (QtWaylandClient::QWaylandDisplay::*)(class QtWaylandClient::QWaylandDisplay * const)) 0x7fffdf8b2640 <QtWaylandClient::QWaylandDisplay::flushRequests()>, o=0x5555555c8390, arg=0x7fffd0002f98)
        at qtbase/src/corelib/kernel/qobjectdefs_impl.h:174
    #57 0x00007fffdf8ce1cb in QtPrivate::QCallableObject<void (QtWaylandClient::QWaylandDisplay::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*)
        (which=1, this_=0x5555555e1390, r=0x5555555c8390, a=0x7fffd0002f98, ret=0x0) at qtbase/src/corelib/kernel/qobjectdefs_impl.h:545
    #58 0x00007fffe3461362 in QtPrivate::QSlotObjectBase::call (this=0x5555555e1390, r=0x5555555c8390, a=0x7fffd0002f98) at qtbase/src/corelib/kernel/qobjectdefs_impl.h:461
    #59 0x00007fffe350ad5c in QMetaCallEvent::placeMetaCall (this=0x7fffd0002f50, object=0x5555555c8390) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qobject.cpp:620
    #60 0x00007fffe350cab1 in QObject::event (this=0x5555555c8390, e=0x7fffd0002f50) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qobject.cpp:1429
    #61 0x00007fffe13e2e20 in QApplicationPrivate::notify_helper (this=0x555555577ae0, receiver=0x5555555c8390, e=0x7fffd0002f50) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3305
    #62 0x00007fffe13e6d3d in QApplication::notify (this=0x555555564d60, receiver=0x5555555c8390, e=0x7fffd0002f50) at /home/michi/development/git/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3255
    #63 0x00007fffe344b419 in QCoreApplication::notifyInternal2 (receiver=0x5555555c8390, event=0x7fffd0002f50) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1112
    #64 0x00007fffe344c089 in QCoreApplication::sendEvent (receiver=0x5555555c8390, event=0x7fffd0002f50) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1552
    #65 0x00007fffe344cfc8 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x55555559f110) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1892
    #66 0x00007fffe344becc in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1746
    #67 0x00007fffe3a3d4a1 in postEventSourceDispatch (s=0x5555555f0f80) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:246
    #68 0x00007fffea10b81f in ??? () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #69 0x00007fffea10da57 in ??? () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #70 0x00007fffea10e1c0 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #71 0x00007fffe3a3c6db in QEventDispatcherGlib::processEvents (this=0x555555568dc0, flags=...) at /home/michi/development/git/qt5/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:399
    #72 0x00007fffe2b7a148 in QPAEventDispatcherGlib::processEvents (this=0x555555568dc0, flags=...) at /home/michi/development/git/qt5/qtbase/src/gui/platform/unix/qeventdispatcher_glib.cpp:89
    #73 0x00007fffe4376a82 in QtInstance::ImplYield (this=0x5555555f5a00, bWait=true, bHandleAllCurrentEvents=false) at vcl/qt6/../qt5/QtInstance.cxx:485
    #74 0x00007fffe4379d51 in QtInstance::DoYield (this=0x5555555f5a00, bWait=true, bHandleAllCurrentEvents=false) at vcl/qt6/../qt5/QtInstance.cxx:496
    #75 0x00007fffeec869b6 in ImplYield (i_bWait=true, i_bAllEvents=false) at /home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:385
    #76 0x00007fffeec862cf in Application::Yield () at /home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:488
    #77 0x00007fffeec860b0 in Application::Execute () at /home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:360
    #78 0x00007ffff7b287f9 in desktop::Desktop::Main (this=0x7fffffffd5d0) at /home/michi/development/git/libreoffice/desktop/source/app/app.cxx:1679
    #79 0x00007fffeeca7e36 in ImplSVMain () at /home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:230
    #80 0x00007fffeeca9a29 in SVMain () at /home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:248
    #81 0x00007ffff7ba20da in soffice_main () at /home/michi/development/git/libreoffice/desktop/source/app/sofficemain.cxx:122
    #82 0x0000555555555a6d in sal_main () at /home/michi/development/git/libreoffice/desktop/source/app/main.c:51
    #83 0x0000555555555a47 in main (argc=2, argv=0x7fffffffd7d8) at /home/michi/development/git/libreoffice/desktop/source/app/main.c:49

Change-Id: Id3832663f5c5c66a4d624054fee4d48219732b95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181155
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
(cherry picked from commit 71d1432)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181542
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
  • Loading branch information
michaelweghorn authored and mistmist committed Feb 13, 2025
1 parent a4da338 commit 252c31f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion accessibility/inc/extended/AccessibleBrowseBox.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private:
class AccessibleBrowseBoxAccess final : public ::vcl::IAccessibleBrowseBox
{
private:
mutable std::mutex m_aMutex;
mutable std::recursive_mutex m_aMutex;
css::uno::Reference< css::accessibility::XAccessible >
m_xParent;
::vcl::IAccessibleTableProvider& m_rBrowseBox;
Expand Down

0 comments on commit 252c31f

Please sign in to comment.