Fix hang during JunitTest_framework_complex on macOS

Desktop / LibreOffice - Stephan Bergmann [redhat.com] - 9 December 2022 09:11 UTC

...when [NSSpellChecker init] is called on a non-main thread, leading to deadlock (see below). The fix is noticing that the first half of SfxFrameLoader_Impl::load and the call to SwGlobals::ensure from Writer_SwTextDocument_getImplementation both don't need to be covered by SolarMutex. Which in turn showed that the call to StartListening from the constructor of SwModule needs to be covered by the SolarMutex (which it no longer was now).

The deadlock was at

> thread #7, name = 'cppu_threadpool::ORequestThread' > #1: libsystem_pthread.dylib`_pthread_cond_wait > #2: Foundation`-[NSOperation waitUntilFinished] > #3: CoreFoundation`_CFXNotificationPost > #4: Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] > #5: AppKit`-[NSMenu insertItem:atIndex:] > #6: AppKit`-[NSApplication(NSServicesMenuPrivate) _fillSpellCheckerPopupButton:] > #7: AppKit`-[NSSpellChecker _fillSpellCheckerPopupButton:] > #8: AppKit`-[NSSpellChecker init] > #9: AppKit`__36+[NSSpellChecker sharedSpellChecker]_block_invoke > #10: libdispatch.dylib`_dispatch_client_callout > #11: libdispatch.dylib`_dispatch_once_callout > #12: AppKit`+[NSSpellChecker sharedSpellChecker] > #13: libMacOSXSpelllo.dylib`MacSpellChecker::getLocales at lingucomponent/source/spellcheck/macosxspell/macspellimp.mm:117:42 > #14: liblnglo.dylib`LngSvcMgr::GetAvailableSpellSvcs_Impl at linguistic/source/lngsvcmgr.cxx:969:63 > #15: liblnglo.dylib`LngSvcMgr::getAvailableServices at linguistic/source/lngsvcmgr.cxx:1395:9 > #16: liblnglo.dylib`LngSvcMgr::getAvailableLocales at linguistic/source/lngsvcmgr.cxx:1459:42 > #17: liblnglo.dylib`LngSvcMgr::UpdateAll at linguistic/source/lngsvcmgr.cxx:654:49 > #18: liblnglo.dylib`LngSvcMgr::LngSvcMgr at linguistic/source/lngsvcmgr.cxx:411:5 > #19: liblnglo.dylib`LngSvcMgr::LngSvcMgr at linguistic/source/lngsvcmgr.cxx:399:1 > #20: liblnglo.dylib`::linguistic_LngSvcMgr_get_implementation at linguistic/source/lngsvcmgr.cxx:1840:30 > #21: libuno_cppuhelpergcc3.dylib.3`decltype(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&)>(fp)(std::__1::forward(fp0), std::__1::forward const&>(fp0))) std::__1::__invoke const&), com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&>(com::sun::star::uno::XInterface* (*&)(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&), com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) > #22: libuno_cppuhelpergcc3.dylib.3`com::sun::star::uno::XInterface* std::__1::__invoke_void_return_wrapper::__call const&), com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&>(com::sun::star::uno::XInterface* (*&)(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&), com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) > #23: libuno_cppuhelpergcc3.dylib.3`std::__1::__function::__alloc_func const&), std::__1::allocator const&)>, com::sun::star::uno::XInterface* (com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&)>::operator(com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) > #24: libuno_cppuhelpergcc3.dylib.3`std::__1::__function::__func const&), std::__1::allocator const&)>, com::sun::star::uno::XInterface* (com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&)>::operator(com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) > #25: libuno_cppuhelpergcc3.dylib.3`std::__1::__function::__value_func const&)>::operator(com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) const > #26: libuno_cppuhelpergcc3.dylib.3`std::__1::function const&)>::operator(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&) const > #27: libuno_cppuhelpergcc3.dylib.3`cppuhelper::ServiceManager::Data::Implementation::doCreateInstance at cppuhelper/source/servicemanager.cxx:702:13 > #28: libuno_cppuhelpergcc3.dylib.3`cppuhelper::ServiceManager::Data::Implementation::createInstance at cppuhelper/source/servicemanager.cxx:667:30 > #29: libuno_cppuhelpergcc3.dylib.3`cppuhelper::ServiceManager::createInstanceWithContext at cppuhelper/source/servicemanager.cxx:1002:36 > #30: libswlo.dylib`com::sun::star::linguistic2::LinguServiceManager::create at workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/linguistic2/LinguServiceManager.hpp:38:129 > #31: libswlo.dylib`SwLinguServiceEventListener::SwLinguServiceEventListener at sw/source/uibase/uno/dlelstnr.cxx:53:22 > #32: libswlo.dylib`SwLinguServiceEventListener::SwLinguServiceEventListener at sw/source/uibase/uno/dlelstnr.cxx:46:1 > #33: libswlo.dylib`SwModule::SwModule at sw/source/uibase/app/swmodule.cxx:161:44 > #34: libswlo.dylib`SwModule::SwModule at sw/source/uibase/app/swmodule.cxx:137:1 > #35: libswlo.dylib`std::__1::__unique_if::__unique_single std::__1::make_unique > #36: libswlo.dylib`SwDLL::SwDLL at sw/source/uibase/app/swdll.cxx:98:26 > #37: libswlo.dylib`SwDLL::SwDLL at sw/source/uibase/app/swdll.cxx:81:1 > #38: libswlo.dylib`(anonymous namespace)::SwDLLInstance::SwDLLInstance at sw/source/uibase/app/swdll.cxx:57:212 > #39: libswlo.dylib`(anonymous namespace)::SwDLLInstance::SwDLLInstance at sw/source/uibase/app/swdll.cxx:58:9 > #40: libswlo.dylib`rtl::Static<(anonymous namespace)::SwDLLInstance, (anonymous namespace)::theSwDLLInstance>::get at include/rtl/instance.hxx:399:18 > #41: libswlo.dylib`SwGlobals::ensure at sw/source/uibase/app/swdll.cxx:70:9 > #42: libswlo.dylib`::Writer_SwTextDocument_get_implementation((null)=0x000000011fde9130, args=0x000000028bb087b0) at sw/source/uibase/uno/unodoc.cxx:40:5 > #43: libuno_cppuhelpergcc3.dylib.3`decltype(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&)>(fp)(std::__1::forward(fp0), std::__1::forward const&>(fp0))) std::__1::__invoke const&), com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&>(com::sun::star::uno::XInterface* (*&)(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&), com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) > #44: libuno_cppuhelpergcc3.dylib.3`com::sun::star::uno::XInterface* std::__1::__invoke_void_return_wrapper::__call const&), com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&>(com::sun::star::uno::XInterface* (*&)(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&), com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) > #45: libuno_cppuhelpergcc3.dylib.3`std::__1::__function::__alloc_func const&), std::__1::allocator const&)>, com::sun::star::uno::XInterface* (com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&)>::operator(com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) > #46: libuno_cppuhelpergcc3.dylib.3`std::__1::__function::__func const&), std::__1::allocator const&)>, com::sun::star::uno::XInterface* (com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&)>::operator(com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) > #47: libuno_cppuhelpergcc3.dylib.3`std::__1::__function::__value_func const&)>::operator(com::sun::star::uno::XComponentContext*&&, com::sun::star::uno::Sequence const&) const > #48: libuno_cppuhelpergcc3.dylib.3`std::__1::function const&)>::operator(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence const&) const > #49: libuno_cppuhelpergcc3.dylib.3`cppuhelper::ServiceManager::Data::Implementation::doCreateInstance at cppuhelper/source/servicemanager.cxx:702:13 > #50: libuno_cppuhelpergcc3.dylib.3`cppuhelper::ServiceManager::Data::Implementation::createInstance at cppuhelper/source/servicemanager.cxx:671:16 > #51: libuno_cppuhelpergcc3.dylib.3`cppuhelper::ServiceManager::createInstanceWithContext at cppuhelper/source/servicemanager.cxx:1002:36 > #52: libsfxlo.dylib`(anonymous namespace)::SfxFrameLoader_Impl::load at sfx2/source/view/frmload.cxx:668:58 > #53: libfwklo.dylib`framework::LoadEnv::impl_loadContent at framework/source/loadenv/loadenv.cxx:1160:37 > #54: libfwklo.dylib`framework::LoadEnv::start at framework/source/loadenv/loadenv.cxx:395:20 > #55: libfwklo.dylib`framework::LoadEnv::startLoading at framework/source/loadenv/loadenv.cxx:300:5 > #56: libfwklo.dylib`framework::LoadEnv::loadComponentFromURL at framework/source/loadenv/loadenv.cxx:168:14 > #57: libfwklo.dylib`framework::Desktop::loadComponentFromURL at framework/source/services/desktop.cxx:605:16 > #58: libgcc3_uno.dylib`callVirtualFunction at bridges/source/cpp_uno/gcc3_linux_aarch64/callvirtualfunction.cxx:38:5 > #59: libgcc3_uno.dylib`(anonymous namespace)::call at bridges/source/cpp_uno/gcc3_linux_aarch64/uno2cpp.cxx:293:13 > #60: libgcc3_uno.dylib`::unoInterfaceProxyDispatch at bridges/source/cpp_uno/gcc3_linux_aarch64/uno2cpp.cxx:505:17 > #61: libbinaryurplo.dylib`binaryurp::IncomingRequest::execute_throw const at binaryurp/source/incomingrequest.cxx:235:13 > #62: libbinaryurplo.dylib`binaryurp::IncomingRequest::execute const at binaryurp/source/incomingrequest.cxx:78:26 > #63: libbinaryurplo.dylib`::request at binaryurp/source/reader.cxx:85:9 > #64: libuno_cppu.dylib.3`cppu_threadpool::JobQueue::enter at cppu/source/threadpool/jobqueue.cxx:100:17 > #65: libuno_cppu.dylib.3`cppu_threadpool::ORequestThread::run at cppu/source/threadpool/thread.cxx:164:31 > #66: libuno_cppu.dylib.3`::threadFunc at include/osl/thread.hxx:189:15 > #67: libuno_sal.dylib.3`osl_thread_start_Impl at sal/osl/unx/thread.cxx:264:9

vs.

> thread #1, queue = 'com.apple.main-thread' > #1: libsystem_pthread.dylib`_pthread_cond_wait > #2: libc++.1.0.dylib`std::__1::condition_variable::wait(std::__1::unique_lock&) [inlined] std::__1::__libcpp_condvar_wait > #3: libc++.1.0.dylib`std::__1::condition_variable::wait > #4: libvclplug_osxlo.dylib`void std::__1::condition_variable::wait > #5: libvclplug_osxlo.dylib`SalYieldMutex::doAcquire at vcl/osx/salinst.cxx:215:36 > #6: libvclplug_osxlo.dylib`comphelper::SolarMutex::acquire at include/comphelper/solarmutex.hxx:86:5 > #7: libvclplug_osxlo.dylib`osl::Guard::Guard at include/osl/mutex.hxx:142:17 > #8: libvclplug_osxlo.dylib`SolarMutexGuard::SolarMutexGuard at include/vcl/svapp.hxx:1348:11 > #9: libvclplug_osxlo.dylib`SolarMutexGuard::SolarMutexGuard at include/vcl/svapp.hxx:1348:78 > #10: libvclplug_osxlo.dylib`AquaSalTimer::callTimerCallback at vcl/osx/saltimer.cxx:140:21 > #11: libvclplug_osxlo.dylib`AquaSalTimer::handleDispatchTimerEvent at vcl/osx/saltimer.cxx:162:9 > #12: libvclplug_osxlo.dylib`AquaSalInstance::handleAppDefinedEvent at vcl/osx/salinst.cxx:406:47 > #13: libvclplug_osxlo.dylib`-[VCL_NSApplication sendEvent:] at vcl/osx/vclnsapp.mm:101:9 > #14: libvclplug_osxlo.dylib`AquaSalInstance::DoYield at vcl/osx/salinst.cxx:567:17 > #15: libvcllo.dylib`ImplYield at vcl/source/app/svapp.cxx:465:48 > #16: libvcllo.dylib`Application::Yield at vcl/source/app/svapp.cxx:532:5 > #17: libvcllo.dylib`Application::Execute at vcl/source/app/svapp.cxx:444:9 > #18: libsofficeapp.dylib`desktop::Desktop::Main at desktop/source/app/app.cxx:1587:13 > #19: libvcllo.dylib`ImplSVMain at vcl/source/app/svmain.cxx:198:35 > #20: libvclplug_osxlo.dylib`AquaSalInstance::handleAppDefinedEvent at vcl/osx/salinst.cxx:396:20 > #21: libvclplug_osxlo.dylib`-[VCL_NSApplication sendEvent:] at vcl/osx/vclnsapp.mm:101:9 > #22: AppKit`-[NSApplication _handleEvent:] > #23: AppKit`-[NSApplication run] > #24: AppKit`NSApplicationMain > #25: libvclplug_osxlo.dylib`AquaSalInstance::SVMainHook at vcl/osx/salinst.cxx:971:5 > #26: libvcllo.dylib`ImplSVMain at vcl/source/app/svmain.cxx:191:54 > #27: libvcllo.dylib`SVMain at vcl/source/app/svmain.cxx:230:12 > #28: libsofficeapp.dylib`soffice_main at desktop/source/app/sofficemain.cxx:98:12 > #29: soffice`sal_main at desktop/source/app/main.c:49:15 > #30: soffice`main at desktop/source/app/main.c:47:1

Change-Id: Ic5681f21a153e42a27680a9a6a179aff38f77fcd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143565

e62462108988 Fix hang during JunitTest_framework_complex on macOS
sfx2/source/view/frmload.cxx | 4 ++--
sw/source/uibase/app/swmodule.cxx | 5 ++++-
sw/source/uibase/uno/unodoc.cxx | 2 +-
3 files changed, 7 insertions(+), 4 deletions(-)

Upstream: cgit.freedesktop.org


  • Share