include/tools/debug.hxx | 13 ++++++++++--- tools/source/debug/debug.cxx | 4 ++-- vcl/qt5/QtInstance.cxx | 1 + vcl/source/app/dbggui.cxx | 8 ++++++-- 4 files changed, 19 insertions(+), 7 deletions(-)
New commits: commit 71e781cbe597a6173e9956e14f82bfa661df9dde Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Wed Feb 19 10:06:16 2025 +0100 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Wed Feb 19 12:38:29 2025 +0100 Introduce DBG_TESTNOTSOLARMUTEX, to complement DBG_TESTSOLARMUTEX ...and use it in one place for the experimental Emscripten Qt6 JSPI/non-PROXY_TO_PTHREAD mode (where I have a hunch that some of the deadlocks I experience in that experimental mode are due to a mis-locked SolarMutex) Change-Id: Ifb335202569b7d2beecd7a502064ebcfdaaddbab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181872 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> diff --git a/include/tools/debug.hxx b/include/tools/debug.hxx index c72da4d06887..e85a6fb3e0ec 100644 --- a/include/tools/debug.hxx +++ b/include/tools/debug.hxx @@ -34,10 +34,10 @@ standard assert. */ -typedef void (*DbgTestSolarMutexProc)(); +typedef void (*DbgTestSolarMutexProc)(bool); TOOLS_DLLPUBLIC void DbgSetTestSolarMutex( DbgTestSolarMutexProc pParam ); -TOOLS_DLLPUBLIC void DbgTestSolarMutex(); +TOOLS_DLLPUBLIC void DbgTestSolarMutex(bool owned); #ifndef NDEBUG // we want the solar mutex checking to be enabled in the assert-enabled builds that the QA people use @@ -45,12 +45,19 @@ TOOLS_DLLPUBLIC void DbgTestSolarMutex(); #define DBG_TESTSOLARMUTEX() \ do \ { \ - DbgTestSolarMutex(); \ + DbgTestSolarMutex(true); \ +} while(false) + +#define DBG_TESTNOTSOLARMUTEX() \ +do \ +{ \ + DbgTestSolarMutex(false); \ } while(false) #else #define DBG_TESTSOLARMUTEX() ((void)0) +#define DBG_TESTNOTSOLARMUTEX() ((void)0) #endif diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx index 197ba2450493..ee6a379d0c5e 100644 --- a/tools/source/debug/debug.cxx +++ b/tools/source/debug/debug.cxx @@ -44,14 +44,14 @@ void DbgSetTestSolarMutex( DbgTestSolarMutexProc pParam ) aDebugData.bTestSolarMutexWasSet = true; } -void DbgTestSolarMutex() +void DbgTestSolarMutex(bool owned) { // don't warn if it was set at least once, because then we're probably just post-DeInitVCL() SAL_WARN_IF( !aDebugData.bTestSolarMutexWasSet && aDebugData.pDbgTestSolarMutex == nullptr, "tools.debug", "no DbgTestSolarMutex function set"); if ( aDebugData.pDbgTestSolarMutex ) - aDebugData.pDbgTestSolarMutex(); + aDebugData.pDbgTestSolarMutex(owned); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx index 1c1f05fa5dc7..779be6ba5f1b 100644 --- a/vcl/qt5/QtInstance.cxx +++ b/vcl/qt5/QtInstance.cxx @@ -242,6 +242,7 @@ void QtInstance::EmscriptenLightweightRunInMainThread_(std::function<void()> fun EM_FUNC_SIG_RETURN_VALUE_V | EM_FUNC_SIG_WITH_N_PARAMETERS(1) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_P), +[](void* pf) { + DBG_TESTNOTSOLARMUTEX(); SolarMutexGuard g; (*static_cast<std::function<void()>*>(pf))(); }, diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx index cfeeeaf5d9ae..ee1a0b72dbd9 100644 --- a/vcl/source/app/dbggui.cxx +++ b/vcl/source/app/dbggui.cxx @@ -30,9 +30,13 @@ using namespace ::com::sun::star; -static void ImplDbgTestSolarMutex() +static void ImplDbgTestSolarMutex(bool owned) { - assert(ImplGetSVData()->mpDefInst->GetYieldMutex()->IsCurrentThread() && "SolarMutex not owned!"); + if (owned) { + assert(ImplGetSVData()->mpDefInst->GetYieldMutex()->IsCurrentThread() && "SolarMutex not owned!"); + } else { + assert(!ImplGetSVData()->mpDefInst->GetYieldMutex()->IsCurrentThread() && "SolarMutex owned!"); + } } void DbgGUIInitSolarMutexCheck()