fix deadlock opening file on android

reported by Michael Weghorn

regression from
    commit 9d1e76f7da
    Author: Noel Grandin <noel.grandin@collabora.co.uk>
    Date:   Tue Jul 1 11:55:03 2025 +0200
    convert PathSettings to comphelper::WeakComponentImplHelper

thread #28, name = 'Thread-2'
frame #0: 0x00007eb9bc494808 libc.so`syscall + 24
frame #1: 0x00007eb9bc47191c libc.so`__futex_wait_ex(void volatile*, bool, int, bool, timespec const*) + 156
frame #2: 0x00007eb9bc480fb1 libc.so`NonPI::MutexLockWithTimeout(pthread_mutex_internal_t*, bool, timespec const*) + 289
frame #3: 0x00007eb6a6d79569 liblo-native-code.so`std::__ndk1::mutex::lock() [inlined] std::__ndk1::__libcpp_mutex_lock[abi:ne200000](__m=<unavailable>) at pthread.h:95:10
frame #4: 0x00007eb6a6d79564 liblo-native-code.so`std::__ndk1::mutex::lock(this=<unavailable>) at mutex.cpp:29:12
frame #5: 0x00007eb69bab18d7 liblo-native-code.so`std::__ndk1::unique_lock<std::__ndk1::mutex>::unique_lock[abi:ne200000](this=0x00007eb71c087c58, __m=0x00007eb8ebf31f00) at unique_lock.h:40:11
frame #6: 0x00007eb69d69faed liblo-native-code.so`(anonymous namespace)::PathSettings::changesOccurred(this=0x00007eb8ebf31d90, aEvent=0x00007eb7bc605918) at pathsettings.cxx:486:22
frame #7: 0x00007eb69d53e2fb liblo-native-code.so`framework::WeakChangesListener::changesOccurred(this=0x00007eb8dc0717d0, rEvent=0x00007eb7bc605918) at mischelper.hxx:204:25
frame #8: 0x00007eb69c2eae41 liblo-native-code.so`configmgr::Broadcaster::send(this=0x00007eb71c0881b8) at broadcaster.cxx:175:41
frame #9: 0x00007eb69c2b8188 liblo-native-code.so`configmgr::Access::setPropertyValue(this=0x00007eb87bf240d0, aPropertyName=0x00007eb6a6f1a328, aValue=0x00007eb71c088478) at access.cxx:776:8
frame #10: 0x00007eb69d55f469 liblo-native-code.so`comphelper::ConfigurationHelper::writeRelativeKey(xCFG=0x00007eb71c0884b8, sRelPath=0x00007eb71c0884c0, sKey=0x00007eb6a6f1a328, aValue=0x00007eb71c088478) at configurationhelper.cxx:106:13
frame #11: 0x00007eb69d6ad622 liblo-native-code.so`(anonymous namespace)::PathSettings::impl_storePath(this=0x00007eb8ebf31d90, g=0x00007eb71c088a18, aPath=0x00007eb71c0887b0) at pathsettings.cxx:660:5
frame #12: 0x00007eb69d6ac994 liblo-native-code.so`(anonymous namespace)::PathSettings::impl_setPathValue(this=0x00007eb8ebf31d90, g=0x00007eb71c088a18, nID=64, aVal=0x00007eb71c088940) at pathsettings.cxx:1231:5
frame #13: 0x00007eb69d6a259b liblo-native-code.so`(anonymous namespace)::PathSettings::setFastPropertyValue_NoBroadcast(this=0x00007eb8ebf31d90, g=0x00007eb71c088a18, nHandle=64, aValue=0x00007eb71c088940) at pathsettings.cxx:1326:5
frame #14: 0x00007eb69c26e5e6 liblo-native-code.so`comphelper::OPropertySetHelper::setFastPropertyValueImpl(this=0x00007eb8ebf31de8, rGuard=0x00007eb71c088a18, nHandle=64, rValue=0x00007eb71c088ae8) at propshlp.cxx:430:9
frame #15: 0x00007eb69c26e1ec liblo-native-code.so`comphelper::OPropertySetHelper::setFastPropertyValue(this=0x00007eb8ebf31de8, nHandle=64, rValue=0x00007eb71c088ae8) at propshlp.cxx:392:5
frame #16: 0x00007eb6a4179629 liblo-native-code.so`SvtPathOptions_Impl::SetPath(this=0x00007eb8ebf308a8, ePath=Temp, rNewPath=0x00007eb71c089268) at pathoptions.cxx:273:26
frame #17: 0x00007eb6a417b872 liblo-native-code.so`SvtPathOptions_Impl::SetTempPath(this=0x00007eb8ebf308a8, rPath=0x00007eb71c089268) at pathoptions.cxx:118:64
frame #18: 0x00007eb6a417b849 liblo-native-code.so`SvtPathOptions::SetTempPath(this=0x00007eb71c089270, rPath=0x00007eb71c089268) at pathoptions.cxx:590:12
frame #19: 0x00007eb6a625d582 liblo-native-code.so`lo_initialize(pThis=0x00007eb77bf1e000, pAppPath="/data/user/0/org.libreoffice/program", pUserProfileUrl=0x0000000000000000) at init.cxx:8520:22
frame #20: 0x00007eb6a625bb00 liblo-native-code.so`libreofficekit_hook_2(install_path="/data/user/0/org.libreoffice/program", user_profile_url=0x0000000000000000) at init.cxx:8627:14
frame #21: 0x00007eb6a625e329 liblo-native-code.so`libreofficekit_hook(install_path="/data/user/0/org.libreoffice/program") at init.cxx:8638:12
frame #22: 0x00007eb6a622e3fc liblo-native-code.so`Java_org_libreoffice_kit_LibreOfficeKit_initializeNative(env=0x00007eb76bef00f0, clazz=0x00007eb64017e380, dataDir=0x00007eb71c089968, cacheDir=0x00007eb71c08996c, apkFile=0x00007eb71c089970, assetManager=0x00007eb71c089974) at libreofficekit-jni.c:177:10
frame #23: 0x00007eb728e2c8cc libart.so`art_quick_generic_jni_trampoline - 18446604748579485491
frame #24: 0x00007eb728e121f7 libart.so`art_quick_invoke_static_stub - 18446604748579593736

Change-Id: Idf5f57bc3e8058a22559a37d84470a8b09e5d151
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187859
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Noel Grandin
2025-07-14 13:32:31 +02:00
parent 8c5b4a4e9e
commit 874b659981

View File

@ -648,6 +648,9 @@ void PathSettings::impl_storePath(std::unique_lock<std::mutex>& g, const PathSet
PathInfo aResubstPath(aPath);
impl_subst(g, aResubstPath, true);
// unlock because writeRelativeKey and friends might trigger a listener which calls back into us
g.unlock();
// update new configuration
if (! aResubstPath.bIsSinglePath)
{
@ -676,6 +679,8 @@ void PathSettings::impl_storePath(std::unique_lock<std::mutex>& g, const PathSet
xProps->setPropertyValue(aResubstPath.sPathName, css::uno::Any());
::comphelper::ConfigurationHelper::flush(xCfgOld);
}
g.lock();
}
// static