desktop/source/lib/init.cxx | 52 ++++++++++++++++++++++---------------------- vcl/source/app/svapp.cxx | 1 2 files changed, 28 insertions(+), 25 deletions(-)
New commits: commit e410ecaebff1a0453d00ef4f4e3673f38f03cfb9 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Jul 22 17:20:20 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Jul 23 09:46:56 2025 +0200 Don't hold the SolarMutex when calling joinThreads hold it during flushBufferedVOCs and during vcl::lok::trimMemory but don't hold it for joinThreads Thread 5 (Thread 0x7fa3cf7fe6c0 (LWP 1721249)): #0 futex_wait (private=0, expected=2, futex_word=0x1b023690) at ../sysdeps/nptl/futex-internal.h:146 #1 __GI___lll_lock_wait (futex=futex@entry=0x1b023690, private=0) at ./nptl/lowlevellock.c:49 #2 0x00007fa3ec6ab4da in lll_mutex_lock_optimized (mutex=0x1b023690) at ./nptl/pthread_mutex_lock.c:48 #3 ___pthread_mutex_lock (mutex=0x1b023690) at ./nptl/pthread_mutex_lock.c:128 #4 0x00007fa3e419eaf6 in osl_acquireMutex () from /opt/collaboraoffice/program/libuno_sal.so.3 #5 0x00007fa3e9e7fa59 in osl::Mutex::acquire (this=0x1b0263a8) at /opt/collaboraoffice/debugsource/include/osl/mutex.hxx:63 #6 SvpSalYieldMutex::doAcquire (this=0x1b0263a0, nLockCount=1) at /opt/collaboraoffice/debugsource/vcl/headless/svpinst.cxx:356 #7 0x00007fa3de30ab73 in comphelper::SolarMutex::acquire (nLockCount=1, this=0x1b0263a0) at /opt/collaboraoffice/debugsource/include/comphelper/solarmutex.hxx:86 #8 osl::Guard<comphelper::SolarMutex>::Guard (t=..., this=<synthetic pointer>) at /opt/collaboraoffice/debugsource/include/osl/mutex.hxx:144 #9 SolarMutexGuard::SolarMutexGuard (this=<synthetic pointer>) at /opt/collaboraoffice/debugsource/include/vcl/svapp.hxx:1343 #10 SwXFlatParagraph::isModified (this=0x7fa3d0022d10) at /opt/collaboraoffice/debugsource/sw/source/core/unocore/unoflatpara.cxx:236 #11 0x00007fa3e7f717ec in GrammarCheckingIterator::ProcessResult (this=0x1e5d42e0, rRes=..., rxFlatParagraphIterator=..., bIsAutomaticChecking=<optimized out>) at /opt/collaboraoffice/debugsource/linguistic/source/gciterator.cxx:399 #12 0x00007fa3e7f7438d in GrammarCheckingIterator::DequeueAndCheck (this=0x1e5d42e0) at /opt/collaboraoffice/debugsource/linguistic/source/gciterator.cxx:719 #13 0x00007fa3e41b2563 in osl_thread_start_Impl(void*) () from /opt/collaboraoffice/program/libuno_sal.so.3 #14 0x00007fa3ec6a81f5 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442 #15 0x00007fa3ec72889c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 Thread 1 (Thread 0x7fa3ec61c7c0 (LWP 1719464)): #0 __futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=1721249, futex_word=0x7fa3cf7fe990) at ./nptl/futex-internal.c:57 #1 __futex_abstimed_wait_common (futex_word=futex_word@entry=0x7fa3cf7fe990, expected=1721249, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=128, cancel=cancel@entry=true) at ./nptl/futex-internal.c:87 #2 0x00007fa3ec6a4f7b in __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x7fa3cf7fe990, expected=<optimized out>, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=128) at ./nptl/futex-internal.c:139 #3 0x00007fa3ec6a9ce3 in __pthread_clockjoin_ex (threadid=140341537662656, thread_return=0x0, clockid=0, abstime=0x0, block=<optimized out>) at ./nptl/pthread_join_common.c:102 #4 0x00007fa3e7f6d1f6 in GrammarCheckingIterator::TerminateThread (this=0x1e5d42e0) at /opt/collaboraoffice/debugsource/linguistic/source/gciterator.cxx:310 #5 0x00007fa3e7f6d23d in GrammarCheckingIterator::joinThreads (this=<optimized out>) at /opt/collaboraoffice/debugsource/linguistic/source/gciterator.cxx:323 #6 0x00007fa3e8940aeb in joinThreads (eCategory=eCategory@entry=(anonymous namespace)::JoinThreads::RESTARTS_ON_DEMAND) at /opt/collaboraoffice/debugsource/desktop/source/lib/init.cxx:3581 #7 0x00007fa3e8940e9f in lo_trimMemory (nTarget=<optimized out>) at /opt/collaboraoffice/debugsource/desktop/source/lib/init.cxx:3392 #8 0x00000000005d9308 in Document::trimIfInactive() () #9 0x0000000000598458 in ChildSession::_handleInput(char const*, int) () #10 0x000000000063476a in Session::handleMessage(std::vector<char, std::allocator<char> > const&) () #11 0x00000000005e17b6 in Document::forwardToChild(std::basic_string_view<char, std::char_traits<char> >, std::vector<char, std::allocator<char> > const&) () #12 0x00000000005e2c88 in Document::drainQueue() () #13 0x00000000005e3372 in KitSocketPoll::kitPoll(int) () #14 0x00007fa3e9e7f1a4 in SvpSalInstance::ImplYield (this=this@entry=0x1b00b490, bWait=bWait@entry=true, bHandleAllCurrentEvents=bHandleAllCurrentEvents@entry=false) at /opt/collaboraoffice/debugsource/vcl/headless/svpinst.cxx:462 Change-Id: I4279eb189c022438924a9f544d4f51295a281e01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188176 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Ashod Nakashian <a...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 4b7c3d2c51b7..49fca80b2f1e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3368,6 +3368,7 @@ static int joinThreads(JoinThreads eCategory); static void flushBufferedVOCs() { + SolarMutexGuard aGuard; // Flush all buffered VOC primitives from the pages. SfxViewShell* pViewShell = SfxViewShell::Current(); if (!pViewShell) @@ -3392,8 +3393,6 @@ static void flushBufferedVOCs() static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget) { - SolarMutexGuard aGuard; - vcl::lok::trimMemory(nTarget); if (nTarget > 2000) @@ -3402,6 +3401,8 @@ static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget) // When more agressively reclaiming memory then shutdown threads which // will restart on demand. + // The SolarMutex should not be held when calling joinThreads to avoid + // deadlock. joinThreads(JoinThreads::RESTARTS_ON_DEMAND); } diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 59cf4c92db9c..8fab026e8673 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -1789,6 +1789,7 @@ void trimMemory(int nTarget) { if (nTarget >= 1000) { + SolarMutexGuard aGuard; ImplSVData* pSVData = ImplGetSVData(); if (!pSVData) // shutting down return; commit 7c620f94f10635d505d35b95cd38fb198a672299 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Jul 22 17:18:19 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Jul 23 09:46:45 2025 +0200 split out block as 'flushBufferedVOCs' for clarity Change-Id: Iad5311722a2a8ef1a10a8cd5196543841081f368 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188175 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 67839304df62..4b7c3d2c51b7 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3366,6 +3366,30 @@ enum class JoinThreads static int joinThreads(JoinThreads eCategory); +static void flushBufferedVOCs() +{ + // Flush all buffered VOC primitives from the pages. + SfxViewShell* pViewShell = SfxViewShell::Current(); + if (!pViewShell) + return; + const SdrView* pView = pViewShell->GetDrawView(); + if (!pView) + return; + SdrPageView* pPageView = pView->GetSdrPageView(); + if (!pPageView) + return; + SdrPage* pCurPage = pPageView->GetPage(); + if (!pCurPage) + return; + SdrModel& sdrModel = pCurPage->getSdrModelFromSdrPage(); + for (sal_uInt16 i = 0; i < sdrModel.GetPageCount(); ++i) + { + SdrPage* pPage = sdrModel.GetPage(i); + if (pPage) + pPage->GetViewContact().flushViewObjectContacts(); + } +} + static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget) { SolarMutexGuard aGuard; @@ -3374,30 +3398,7 @@ static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget) if (nTarget > 2000) { - // Flush all buffered VOC primitives from the pages. - SfxViewShell* pViewShell = SfxViewShell::Current(); - if (pViewShell) - { - const SdrView* pView = pViewShell->GetDrawView(); - if (pView) - { - SdrPageView* pPageView = pView->GetSdrPageView(); - if (pPageView) - { - SdrPage* pCurPage = pPageView->GetPage(); - if (pCurPage) - { - SdrModel& sdrModel = pCurPage->getSdrModelFromSdrPage(); - for (sal_uInt16 i = 0; i < sdrModel.GetPageCount(); ++i) - { - SdrPage* pPage = sdrModel.GetPage(i); - if (pPage) - pPage->GetViewContact().flushViewObjectContacts(); - } - } - } - } - } + flushBufferedVOCs(); // When more agressively reclaiming memory then shutdown threads which // will restart on demand.