From 48916eb11bea29ac2f7963d779b18491d6015737 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Mon, 16 Jan 2023 11:23:21 +0100 Subject: tdf#153009 Use recursive mutex in CDocumentBuilder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was changed from `osl::Mutex` to `std::mutex` in commit e66fdb597b30fc701bb068824d0ae4d89fecd55f Date: Sat Jul 31 20:12:30 2021 +0200 osl::Mutex->std::mutex in CDocumentBuilder , but `DOM::CDocumentBuilder::parseURI` locks the mutex and then calls `DOM::CDocumentBuilder::parse` for the // if we failed to parse the URI as a simple file, lets try via a ucb stream. // For Android file:///assets/ URLs which must go via the osl/ file API. case, which would result in a deadlock because `DOM::CDocumentBuilder::parse` wants to lock the mutex again. This happens once that code path is executed on Android Viewer when creating a new Impress presentation with Change-Id Iba1ac68c0b983d3e465515f07b3fc67162a0ee3f ("tdf#153009 android: Include more doc layout related XML files") in place. Fix the deadlock by using a "std::recursive_mutex` instead. Part of the backtrace: DOM::CDocumentBuilder::parse(const com::sun::star::uno::Reference<…> &) documentbuilder.cxx:331 DOM::CDocumentBuilder::parseURI(const rtl::OUString &) documentbuilder.cxx:387 non-virtual thunk to DOM::CDocumentBuilder::parseURI(rtl::OUString const&) documentbuilder.cxx:0 SdDrawDocument::InitLayoutVector() drawdoc.cxx:1130 SdDrawDocument::SdDrawDocument(DocumentType, SfxObjectShell *) drawdoc.cxx:147 sd::DrawDocShell::Construct(bool) docshell.cxx:94 sd::DrawDocShell::DrawDocShell(SfxModelFlags, bool, DocumentType) docshell.cxx:140 sd_PresentationDocument_get_implementation::$_1::operator()(SfxModelFlags) const unodoc.cxx:65 std::__ndk1::__invoke<…>(sd_PresentationDocument_get_implementation::$_1 &, SfxModelFlags &&) type_traits:4353 std::__ndk1::__invoke_void_return_wrapper::__call<…>(sd_PresentationDocument_get_implementation::$_1 &, SfxModelFlags &&) __functional_base:318 std::__ndk1::__function::__alloc_func::operator()(SfxModelFlags &&) functional:1527 std::__ndk1::__function::__func::operator()(SfxModelFlags &&) functional:1651 std::__ndk1::__function::__value_func::operator()(SfxModelFlags &&) const functional:1799 std::__ndk1::function::operator()(SfxModelFlags) const functional:2347 sfx2::createSfxModelInstance(const com::sun::star::uno::Sequence<…> &, std::__ndk1::function<…>) sfxmodelfactory.cxx:82 sd_PresentationDocument_get_implementation(com::sun::star::uno::XComponentContext *, const com::sun::star::uno::Sequence<…> &) unodoc.cxx:61 std::__ndk1::__invoke<…>(com::sun::star::uno::XInterface *(*&)(com::sun::star::uno::XComponentContext *, const com::sun::star::uno::Sequence<…> &), com::sun::star::uno::XComponentContext *&&, const com::sun::star::uno::Sequence<…> &) type_traits:4353 std::__ndk1::__invoke_void_return_wrapper::__call<…>(com::sun::star::uno::XInterface *(*&)(com::sun::star::uno::XComponentContext *, const com::sun::star::uno::Sequence<…> &), com::sun::star::uno::XComponentContext *&&, const com::sun::star::uno::Sequence<…> &) __functional_base:318 std::__ndk1::__function::__alloc_func::operator()(com::sun::star::uno::XComponentContext *&&, const com::sun::star::uno::Sequence<…> &) functional:1527 std::__ndk1::__function::__func::operator()(com::sun::star::uno::XComponentContext *&&, const com::sun::star::uno::Sequence<…> &) functional:1651 std::__ndk1::__function::__value_func::operator()(com::sun::star::uno::XComponentContext *&&, const com::sun::star::uno::Sequence<…> &) const functional:1799 std::__ndk1::function::operator()(com::sun::star::uno::XComponentContext *, const com::sun::star::uno::Sequence<…> &) const functional:2347 cppuhelper::ServiceManager::Data::Implementation::doCreateInstance(const com::sun::star::uno::Reference<…> &) servicemanager.cxx:706 cppuhelper::ServiceManager::Data::Implementation::createInstance(const com::sun::star::uno::Reference<…> &, bool) servicemanager.cxx:675 cppuhelper::ServiceManager::createInstanceWithContext(const rtl::OUString &, const com::sun::star::uno::Reference<…> &) servicemanager.cxx:1006 non-virtual thunk to cppuhelper::ServiceManager::createInstanceWithContext(rtl::OUString const&, com::sun::star::uno::Reference const&) servicemanager.cxx:0 SfxFrameLoader_Impl::load(const com::sun::star::uno::Sequence<…> &, const com::sun::star::uno::Reference<…> &) frmload.cxx:707 non-virtual thunk to (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence const&, com::sun::star::uno::Reference const&) frmload.cxx:0 framework::LoadEnv::impl_loadContent() loadenv.cxx:1167 framework::LoadEnv::start() loadenv.cxx:403 framework::LoadEnv::startLoading(const rtl::OUString &, const com::sun::star::uno::Sequence<…> &, const com::sun::star::uno::Reference<…> &, const rtl::OUString &, long, LoadEnvFeatures) loadenv.cxx:308 framework::LoadEnv::loadComponentFromURL(const com::sun::star::uno::Reference<…> &, const com::sun::star::uno::Reference<…> &, const rtl::OUString &, const rtl::OUString &, long, const com::sun::star::uno::Sequence<…> &) loadenv.cxx:168 framework::Desktop::loadComponentFromURL(const rtl::OUString &, const rtl::OUString &, long, const com::sun::star::uno::Sequence<…> &) desktop.cxx:594 non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, long, com::sun::star::uno::Sequence const&) desktop.cxx:0 lo_documentLoadWithOptions(_LibreOfficeKit *, const char *, const char *) init.cxx:2666 lo_documentLoad(_LibreOfficeKit *, const char *) init.cxx:2532 Java_org_libreoffice_kit_Office_documentLoadNative(JNIEnv *, jobject, jstring) lokandroid.cxx:134 [...] Change-Id: I63bc7b6f682dab2e94f4e932429c513c5129428e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145620 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- unoxml/source/dom/documentbuilder.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unoxml/source') diff --git a/unoxml/source/dom/documentbuilder.hxx b/unoxml/source/dom/documentbuilder.hxx index b29e0410e76e..7b93b170d4c1 100644 --- a/unoxml/source/dom/documentbuilder.hxx +++ b/unoxml/source/dom/documentbuilder.hxx @@ -46,7 +46,7 @@ namespace DOM : public CDocumentBuilder_Base { private: - std::mutex m_Mutex; + std::recursive_mutex m_Mutex; css::uno::Reference< css::xml::sax::XEntityResolver > m_xEntityResolver; css::uno::Reference< css::xml::sax::XErrorHandler > m_xErrorHandler; -- cgit