unotools/source/config/useroptions.cxx |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 2d93fd2631b4f8ceca1068c1779963424ff90e80
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri May 13 20:51:28 2022 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri May 13 22:42:09 2022 +0200

    std::mutex->std::recursive_mutex in SvtUserOptions
    
    Since commit ac511d90cdf9d28eb8809c30be9fa08b42ea0bd3
      Author Noel Grandin <noelgran...@gmail.com>
      Date   Thu Dec 23 19:42:19 2021 +0200
        osl::Mutex->std::mutex in SvtUserOptions
    
    non-recursive std::mutex is used. However, it looks like recursive
    locking is possible here, as shows the debugging that I made
    during the work on https://gerrit.libreoffice.org/c/core/+/134251.
    The call stack looks like this:
    
      utllo.dll!SvtUserOptions::GetToken(UserOptToken nToken) Line 318
      utllo.dll!SvtUserOptions::GetLastName() Line 294
      
sclo.dll!ScChangeTrack::ConfigurationChanged(utl::ConfigurationBroadcaster * 
__formal, ConfigurationHints __formal) Line 2166
      
utllo.dll!utl::ConfigurationBroadcaster::NotifyListeners(ConfigurationHints 
nHint) Line 85
      
utllo.dll!utl::detail::Options::ConfigurationChanged(utl::ConfigurationBroadcaster
 * __formal, ConfigurationHints nHint) Line 112
      
utllo.dll!utl::ConfigurationBroadcaster::NotifyListeners(ConfigurationHints 
nHint) Line 85
      utllo.dll!SvtUserOptions::Impl::Notify() Line 251
      utllo.dll!SvtUserOptions::ChangeListener::changesOccurred(const 
com::sun::star::util::ChangesEvent & rEvent) Line 116
      configmgrlo.dll!configmgr::Broadcaster::send() Line 168
      configmgrlo.dll!configmgr::Access::setPropertyValue(const rtl::OUString & 
aPropertyName, const com::sun::star::uno::Any & aValue) Line 714
      utllo.dll!SvtUserOptions::Impl::SetValue_Impl<rtl::OUString>(UserOptToken 
nToken, const rtl::OUString & sToken) Line 183
      utllo.dll!SvtUserOptions::Impl::SetToken(UserOptToken nToken, const 
rtl::OUString & sToken) Line 200
      utllo.dll!SvtUserOptions::SetToken(UserOptToken nToken, const 
rtl::OUString & rNewToken) Line 325
      
test_sc_subsequent_export_test.dll!ScExportTest::testTrackChangesSimpleXLSX() 
Line 3072
      ...
    
    So getting the token may happen during notification of the listeners
    after setting the token, in the same thread. So let's use recursive
    mutex.
    
    Change-Id: I9be82f307a9948bcbc76d7d90632a0307c5dc4f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134190
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/unotools/source/config/useroptions.cxx 
b/unotools/source/config/useroptions.cxx
index 86a42e84bae2..61273bfbe9fb 100644
--- a/unotools/source/config/useroptions.cxx
+++ b/unotools/source/config/useroptions.cxx
@@ -259,9 +259,9 @@ bool SvtUserOptions::Impl::IsTokenReadonly (UserOptToken 
nToken) const
             beans::PropertyAttribute::READONLY);
 }
 
-static std::mutex& GetInitMutex()
+static std::recursive_mutex& GetInitMutex()
 {
-    static std::mutex gMutex;
+    static std::recursive_mutex gMutex;
     return gMutex;
 }
 

Reply via email to