sd/source/console/PresenterSlideShowView.cxx |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

New commits:
commit be60f7aeab350cfbd507eff68915368fe33006ad
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Jul 5 09:37:20 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Jul 5 13:39:20 2025 +0200

    sd console: Fix deadlock when exiting presentation mode
    
    Since
    
        commit 380bd856d1a67a4e2db27162502a6fb56e17899a
        Date:   Tue Jun 24 11:21:04 2025 +0200
    
            [API CHANGE] remove css::drawing::framework::XView
    
    , starting an Impress presentation in a dual screen setup
    with presenter console enabled, then existing the presentation
    resulted in a deadlock with the below backtrace, because
    WeakComponentImplHelperBase::dispose (frame 9)
    locks the base class's UnoImplBase::m_aMutex and then
    sdext::presenter::PresenterSlideShowView::disposing (frame 8)
    tries to lock it again.
    
    Use the existing lock passed as a method param and pass it
    down to the called methods instead. Add an assert
    it is actually a lock for the correct mutex.
    
        #0  futex_wait (futex_word=0x55555d5afb70, expected=2, private=0) at 
../sysdeps/nptl/futex-internal.h:146
        #1  __GI___lll_lock_wait (futex=futex@entry=0x55555d5afb70, private=0) 
at ./nptl/lowlevellock.c:49
        #2  0x00007ffff789ff72 in lll_mutex_lock_optimized 
(mutex=0x55555d5afb70) at ./nptl/pthread_mutex_lock.c:48
        #3  ___pthread_mutex_lock (mutex=0x55555d5afb70) at 
./nptl/pthread_mutex_lock.c:93
        #4  0x00007fffc768849f in __gthread_mutex_lock (__mutex=0x55555d5afb70) 
at 
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:762
        #5  0x00007fffc7693185 in std::mutex::lock (this=0x55555d5afb70) at 
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/std_mutex.h:113
        #6  0x00007fffc7693154 in std::unique_lock<std::mutex>::lock 
(this=0x7fffffff8838) at 
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_lock.h:147
        #7  0x00007fffc768b068 in std::unique_lock<std::mutex>::unique_lock 
(this=0x7fffffff8838, __m=...) at 
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_lock.h:73
        #8  0x00007fffc76f408c in 
sdext::presenter::PresenterSlideShowView::disposing (this=0x55555d5afa10) at 
/home/michi/development/git/libreoffice/sd/source/console/PresenterSlideShowView.cxx:186
        #9  0x00007ffff6134bb0 in 
comphelper::WeakComponentImplHelperBase::dispose (this=0x55555d5afa10) at 
/home/michi/development/git/libreoffice/comphelper/source/misc/compbase.cxx:26
        #10 0x00007fffc76a4885 in 
comphelper::WeakComponentImplHelper<>::dispose() (this=0x55555d5afa10) at 
include/comphelper/compbase.hxx:78
        #11 0x00007fffc7783b71 in 
sdext::presenter::PresenterViewFactory::releaseResource (this=0x55555d649400, 
rxView=rtl::Reference to 0x55555d5afa10) at 
/home/michi/development/git/libreoffice/sd/source/console/PresenterViewFactory.cxx:229
        #12 0x00007fffbb192dec in 
sd::framework::ConfigurationControllerResourceManager::DeactivateResource 
(this=0x555557655ca0, rxResourceId=rtl::Reference to 0x55555d6492f0, 
rxConfiguration=rtl::Reference to 0x555556a598e0)
            at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ConfigurationControllerResourceManager.cxx:203
        #13 0x00007fffbb193814 in 
sd::framework::ConfigurationControllerResourceManager::DeactivateResources(std::__debug::vector<rtl::Reference<sd::framework::ResourceId>,
 std::allocator<rtl::Reference<sd::framework::ResourceId> > > const&, 
rtl::Reference<sd::framework::Configuration> 
const&)::$_0::operator()(rtl::Reference<sd::framework::ResourceId> const&) 
const (this=0x7fffffff9290, xResource=rtl::Reference to 0x55555d6492f0)
            at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ConfigurationControllerResourceManager.cxx:90
        #14 0x00007fffbb192a9b in 
std::for_each<std::reverse_iterator<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<rtl::Reference<sd::framework::ResourceId>
 const*, std::__cxx1998::vector<rtl::Reference<sd::framework::ResourceId>, 
std::allocator<rtl::Reference<sd::framework::ResourceId> > > >, 
std::__debug::vector<rtl::Reference<sd::framework::ResourceId>, 
std::allocator<rtl::Reference<sd::framework::ResourceId> > >, 
std::random_access_iterator_tag> >, 
sd::framework::ConfigurationControllerResourceManager::DeactivateResources(std::__debug::vector<rtl::Reference<sd::framework::ResourceId>,
 std::allocator<rtl::Reference<sd::framework::ResourceId> > > const&, 
rtl::Reference<sd::framework::Configuration> 
const&)::$_0>(std::reverse_iterator<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<rtl::Reference<sd::framework::ResourceId>
 const*, std::__cxx1998::vector<rtl::Reference<sd::framework::ResourceId>, 
std::allocator<rtl::Reference<sd::framework::ResourceId> > > >, std
 ::__debug::vector<rtl::Reference<sd::framework::ResourceId>, 
std::allocator<rtl::Reference<sd::framework::ResourceId> > >, 
std::random_access_iterator_tag> >, 
std::reverse_iterator<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<rtl::Reference<sd::framework::ResourceId>
 const*, std::__cxx1998::vector<rtl::Reference<sd::framework::ResourceId>, 
std::allocator<rtl::Reference<sd::framework::ResourceId> > > >, 
std::__debug::vector<rtl::Reference<sd::framework::ResourceId>, 
std::allocator<rtl::Reference<sd::framework::ResourceId> > >, 
std::random_access_iterator_tag> >, 
sd::framework::ConfigurationControllerResourceManager::DeactivateResources(std::__debug::vector<rtl::Reference<sd::framework::ResourceId>,
 std::allocator<rtl::Reference<sd::framework::ResourceId> > > const&, 
rtl::Reference<sd::framework::Configuration> const&)::$_0) (__first=..., 
__last=..., __f=...)
            at 
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_algo.h:3786
        #15 0x00007fffbb192844 in 
sd::framework::ConfigurationControllerResourceManager::DeactivateResources
            (this=0x555557655ca0, rResources=std::__debug::vector of length 7, 
capacity 7 = {...}, rxConfiguration=rtl::Reference to 0x555556a598e0)
            at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ConfigurationControllerResourceManager.cxx:86
        #16 0x00007fffbb19a50e in 
sd::framework::ConfigurationUpdater::UpdateCore (this=0x555557657360, 
rClassifier=...) at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx:250
        #17 0x00007fffbb199afc in 
sd::framework::ConfigurationUpdater::UpdateConfiguration (this=0x555557657360) 
at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx:161
        #18 0x00007fffbb19957b in 
sd::framework::ConfigurationUpdater::RequestUpdate (this=0x555557657360, 
rxRequestedConfiguration=rtl::Reference to 0x555556a5a320)
            at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx:108
        #19 0x00007fffbb16d349 in 
sd::framework::ChangeRequestQueueProcessor::ProcessOneEvent 
(this=0x555557657f30) at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx:158
        #20 0x00007fffbb16cd9f in 
sd::framework::ChangeRequestQueueProcessor::ProcessEvent (this=0x555557657f30) 
at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx:115
        #21 0x00007fffbb16cd4d in 
sd::framework::ChangeRequestQueueProcessor::LinkStubProcessEvent 
(instance=0x555557657f30, data=0x0)
            at 
/home/michi/development/git/libreoffice/sd/source/ui/framework/configuration/ChangeRequestQueueProcessor.cxx:109
        #22 0x00007fffee275c21 in Link<void*, void>::Call (this=0x55555880a688, 
data=0x0) at include/tools/link.hxx:105
        #23 0x00007fffee271e51 in ImplHandleUserEvent (pSVEvent=0x55555880a680) 
at /home/michi/development/git/libreoffice/vcl/source/window/winproc.cxx:2285
        #24 0x00007fffee26ed7f in ImplWindowFrameProc (_pWindow=0x5555569e6b00, 
nEvent=SalEvent::UserEvent, pEvent=0x55555880a680) at 
/home/michi/development/git/libreoffice/vcl/source/window/winproc.cxx:2849
        #25 0x00007fffeee478bc in SalFrame::CallCallback (this=0x55555688b5d0, 
nEvent=SalEvent::UserEvent, pEvent=0x55555880a680) at vcl/inc/salframe.hxx:310
        #26 0x00007fffeee7021f in SalGenericDisplay::ProcessEvent 
(this=0x5555568a4060, aEvent=...) at 
/home/michi/development/git/libreoffice/vcl/unx/generic/app/gendisp.cxx:66
        #27 0x00007fffee97bd7d in 
SalUserEventList::DispatchUserEvents(bool)::$_0::operator()() const 
(this=0x7fffffffb920) at 
/home/michi/development/git/libreoffice/vcl/source/app/salusereventlist.cxx:119
        #28 0x00007fffee97bc4b in SalUserEventList::DispatchUserEvents 
(this=0x5555568a4060, bHandleAllCurrentEvents=false) at 
/home/michi/development/git/libreoffice/vcl/source/app/salusereventlist.cxx:120
        #29 0x00007fffeee70175 in SalGenericDisplay::DispatchInternalEvent 
(this=0x5555568a4060, bHandleAllCurrentEvent=false) at 
/home/michi/development/git/libreoffice/vcl/unx/generic/app/gendisp.cxx:51
        #30 0x00007fffe628460f in call_userEventFn (data=0x5555555b3ab0) at 
/home/michi/development/git/libreoffice/vcl/unx/gtk3/gtkdata.cxx:825
        #31 0x00007fffe99043c5 in ??? () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
        #32 0x00007fffe99065f7 in ??? () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
        #33 0x00007fffe9906d60 in g_main_context_iteration () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
        #34 0x00007fffe628328c in GtkSalData::Yield (this=0x5555555b3ab0, 
bWait=true, bHandleAllCurrentEvents=false) at 
/home/michi/development/git/libreoffice/vcl/unx/gtk3/gtkdata.cxx:403
        #35 0x00007fffe6288333 in GtkInstance::DoYield (this=0x5555555b3960, 
bWait=true, bHandleAllCurrentEvents=false) at 
/home/michi/development/git/libreoffice/vcl/unx/gtk3/gtkinst.cxx:439
        #36 0x00007fffeea47b16 in ImplYield (i_bWait=true, i_bAllEvents=false) 
at /home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:385
        #37 0x00007fffeea4742f in Application::Yield () at 
/home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:488
        #38 0x00007fffeea47210 in Application::Execute () at 
/home/michi/development/git/libreoffice/vcl/source/app/svapp.cxx:360
        #39 0x00007ffff7b297a5 in desktop::Desktop::Main (this=0x7fffffffd660) 
at /home/michi/development/git/libreoffice/desktop/source/app/app.cxx:1678
        #40 0x00007fffeea71846 in ImplSVMain () at 
/home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:230
        #41 0x00007fffeea73339 in SVMain () at 
/home/michi/development/git/libreoffice/vcl/source/app/svmain.cxx:248
        #42 0x00007ffff7ba40ba in soffice_main () at 
/home/michi/development/git/libreoffice/desktop/source/app/sofficemain.cxx:122
        #43 0x00005555555559fd in sal_main () at 
/home/michi/development/git/libreoffice/desktop/source/app/main.c:51
        #44 0x00005555555559d7 in main (argc=2, argv=0x7fffffffd868) at 
/home/michi/development/git/libreoffice/desktop/source/app/main.c:49
    
    Change-Id: I2f0cc4db777c3e6e2db3d2ec7756bc89f43f0093
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187436
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sd/source/console/PresenterSlideShowView.cxx 
b/sd/source/console/PresenterSlideShowView.cxx
index 9fc93a899020..b7286e60ce4b 100644
--- a/sd/source/console/PresenterSlideShowView.cxx
+++ b/sd/source/console/PresenterSlideShowView.cxx
@@ -176,19 +176,17 @@ PresenterSlideShowView::~PresenterSlideShowView()
 {
 }
 
-void PresenterSlideShowView::disposing(std::unique_lock<std::mutex>&)
+void PresenterSlideShowView::disposing(std::unique_lock<std::mutex>& rLock)
 {
     // Tell all listeners that we are disposed.
     lang::EventObject aEvent;
     aEvent.Source = static_cast<XWeak*>(this);
 
-    {
-        std::unique_lock l(m_aMutex);
-        maMouseListeners.disposeAndClear(l, aEvent);
-        maMouseMotionListeners.disposeAndClear(l, aEvent);
-        maPaintListeners.disposeAndClear(l, aEvent);
-        maModifyListeners.disposeAndClear(l, aEvent);
-    }
+    assert(rLock.mutex() == &m_aMutex);
+    maMouseListeners.disposeAndClear(rLock, aEvent);
+    maMouseMotionListeners.disposeAndClear(rLock, aEvent);
+    maPaintListeners.disposeAndClear(rLock, aEvent);
+    maModifyListeners.disposeAndClear(rLock, aEvent);
 
     // Do this for
     // XPaintListener, 
XModifyListener,XMouseListener,XMouseMotionListener,XWindowListener?

Reply via email to