[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - stoc/source

Michael Stahl mstahl at redhat.com
Tue Aug 22 11:45:30 UTC 2017


 stoc/source/proxy_factory/proxyfac.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 503932438d5e7c77d73bcbcda3c727ee7e54920f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Aug 21 22:40:57 2017 +0200

    stoc: deadlock osl::Mutex::getGlobalMutex() vs getImplHelperInitMutex()
    
    As found in a clang/ASAN build running UITest_writer_demo.
    
    cppu::getTypeEntries locks getImplHelperInitMutex().
    
    Let's try to replace the usage of getGlobalMutex() in proxyfac_create()
    with a new static Mutex that is only used in that function.
    
    {1: 7, 6: 1, 7: 1}
    Thread 1 is waiting for 7
    Thread 7 is waiting for 1
    
    Thread 7 (Thread 0x7f34a147a700 (LWP 2530)):
    2  osl_acquireMutex(oslMutexImpl*) (pMutex=0x7f34f620a3e0 <globalMutexImpl>) at sal/osl/unx/mutex.cxx:97
    3  osl::Mutex::acquire() (this=0x7f34f61f7da0 <osl_getGlobalMutex::globalMutex>) at include/osl/mutex.hxx:56
    4  osl::Guard<osl::Mutex>::Guard(osl::Mutex*) (this=0x7f349f6dc420, pT_=0x7f34f61f7da0 <osl_getGlobalMutex::globalMutex>) at include/osl/mutex.hxx:122
    5  com::sun::star::lang::cppu_detail_getUnoType(com::sun::star::lang::XSingleComponentFactory const*) () at workdir/UnoApiHeadersTarget/udkapi/normal/com/sun/star/lang/XSingleComponentFactory.hpp:69
    6  cppu::UnoType<com::sun::star::lang::XSingleComponentFactory>::get() () at include/cppu/unotype.hxx:296
    7  com::sun::star::lang::XSingleComponentFactory::static_type(void*) () at workdir/UnoApiHeadersTarget/udkapi/normal/com/sun/star/lang/XSingleComponentFactory.hpp:146
    8  cppu::getTypeEntries(cppu::class_data*) (cd=0x7f34bddacb40 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::lang::XSingleComponentFactory, com::sun::star::lang::XServiceInfo>, com::sun::star::lang::XSingleComponentFactory, com::sun::star::lang::XServiceInfo>::operator()()::s_cd>) at cppuhelper/source/implbase_ex.cxx:96
    9  cppu::queryDeepNoXInterface(_typelib_TypeDescriptionReference const*, cppu::class_data*, void*) (pDemandedTDR=0x60f000042940, cd=0x7f34bddacb40 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::lang::XSingleComponentFactory, com::sun::star::lang::XServiceInfo>, com::sun::star::lang::XSingleComponentFactory, com::sun::star::lang::XServiceInfo>::operator()()::s_cd>, that=0x606000d3d3c0) at cppuhelper/source/implbase_ex.cxx:168
    10 cppu::WeakImplHelper_query(com::sun::star::uno::Type const&, cppu::class_data*, void*, cppu::OWeakObject*) (rType=invalid uno::Type, cd=0x7f34bddacb40 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::lang::XSingleComponentFactory, com::sun::star::lang::XServiceInfo>, com::sun::star::lang::XSingleComponentFactory, com::sun::star::lang::XServiceInfo>::operator()()::s_cd>, that=0x606000d3d3c0, pBase=0x606000d3d3c0) at cppuhelper/source/implbase_ex.cxx:296
    11 cppu::WeakImplHelper<com::sun::star::lang::XSingleComponentFactory, com::sun::star::lang::XServiceInfo>::queryInterface(com::sun::star::uno::Type const&) (this=0x606000d3d3c0, aType=invalid uno::Type) at include/cppuhelper/implbase.hxx:108
    12 non-virtual thunk to cppu::WeakImplHelper<com::sun::star::lang::XSingleComponentFactory, com::sun::star::lang::XServiceInfo>::queryInterface(com::sun::star::uno::Type const&) () at include/cppuhelper/implbase.hxx:107
    13 com::sun::star::uno::BaseReference::iquery(com::sun::star::uno::XInterface*, com::sun::star::uno::Type const&) (pInterface=0x606000d3d3e8, rType=invalid uno::Type) at include/com/sun/star/uno/Reference.hxx:55
    14 com::sun::star::uno::Reference<com::sun::star::lang::XSingleComponentFactory>::iquery(com::sun::star::uno::XInterface*) (pInterface=0x606000d3d3e8) at include/com/sun/star/uno/Reference.hxx:70
    15 com::sun::star::uno::Reference<com::sun::star::lang::XSingleComponentFactory>::set(com::sun::star::uno::BaseReference const&, com::sun::star::uno::UnoReference_Query) (this=0x7f349f92b7e0, rRef=...) at include/com/sun/star/uno/Reference.hxx:279
    16 cppuhelper::ServiceManager::loadImplementation(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, std::shared_ptr<cppuhelper::ServiceManager::Data::Implementation> const&) (this=0x61500000e900, context=uno::Reference to (cppu::ComponentContext *) 0x611000003b50, implementation=warning: RTTI symbol not found for class 'std::_Sp_counted_ptr<cppuhelper::ServiceManager::Data::Implementation*, (__gnu_cxx::_Lock_policy)2>'
    arnound for class 'std::_Sp_counted_ptr<cppuhelper::ServiceManager::Data::Implementation*, (__gnu_cxx::_Lock_policy)2>'
    td:weak 0) 0x60b000013ff0) at cppuhelper/source/servicemanager.cxx:823
    17 cppuhelper::ServiceManager::findServiceImplementation(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&) (this=0x61500000e900, context=uno::Reference to (cppu::ComponentContext *) 0x611000003b50, specifier="com.sun.star.configuration.ConfigurationProvider") at cppuhelper/source/servicemanager.cxx:1811
    18 cppuhelper::ServiceManager::createInstanceWithContext(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x61500000e900, aServiceSpecifier="com.sun.star.configuration.ConfigurationProvider", Context=uno::Reference to (cppu::ComponentContext *) 0x611000003b50) at cppuhelper/source/servicemanager.cxx:993
    19 cppuhelper::ServiceManager::createInstance(rtl::OUString const&) (this=0x61500000e900, aServiceSpecifier="com.sun.star.configuration.ConfigurationProvider") at cppuhelper/source/servicemanager.cxx:950
    
    Thread 1 (Thread 0x7f34f632b4c0 (LWP 2487)):
    2  osl_acquireMutex(oslMutexImpl*) (pMutex=0x604000098a90) at sal/osl/unx/mutex.cxx:97
    3  osl::Mutex::acquire() (this=0x7f34f12fa820 <rtl::Static<osl::Mutex, (anonymous namespace)::theImplHelperInitMutex>::get()::instance>) at include/osl/mutex.hxx:56
    4  osl::Guard<osl::Mutex>::Guard(osl::Mutex&) (this=0x7f34c6611420, t=...) at include/osl/mutex.hxx:129
    5  cppu::getTypeEntries(cppu::class_data*) (cd=0x7f3498adf290 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::lang::XServiceInfo, com::sun::star::reflection::XProxyFactory>, com::sun::star::lang::XServiceInfo, com::sun::star::reflection::XProxyFactory>::operator()()::s_cd>) at cppuhelper/source/implbase_ex.cxx:89
    6  cppu::queryDeepNoXInterface(_typelib_TypeDescriptionReference const*, cppu::class_data*, void*) (pDemandedTDR=0x60f00003c6d0, cd=0x7f3498adf290 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::lang::XServiceInfo, com::sun::star::reflection::XProxyFactory>, com::sun::star::lang::XServiceInfo, com::sun::star::reflection::XProxyFactory>::operator()()::s_cd>, that=0x6080005aa620) at cppuhelper/source/implbase_ex.cxx:168
    7  cppu::WeakImplHelper_query(com::sun::star::uno::Type const&, cppu::class_data*, void*, cppu::OWeakObject*) (rType=invalid uno::Type, cd=0x7f3498adf290 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::lang::XServiceInfo, com::sun::star::reflection::XProxyFactory>, com::sun::star::lang::XServiceInfo, com::sun::star::reflection::XProxyFactory>::operator()()::s_cd>, that=0x6080005aa620, pBase=0x6080005aa620) at cppuhelper/source/implbase_ex.cxx:296
    8  cppu::WeakImplHelper<com::sun::star::lang::XServiceInfo, com::sun::star::reflection::XProxyFactory>::queryInterface(com::sun::star::uno::Type const&) (this=0x6080005aa620, aType=invalid uno::Type) at include/cppuhelper/implbase.hxx:108
    9  com::sun::star::uno::BaseReference::iquery(com::sun::star::uno::XInterface*, com::sun::star::uno::Type const&) (pInterface=0x6080005aa620, rType=invalid uno::Type) at include/com/sun/star/uno/Reference.hxx:55
    10 com::sun::star::uno::Reference<com::sun::star::uno::XWeak>::iquery(com::sun::star::uno::XInterface*) (pInterface=0x6080005aa620) at include/com/sun/star/uno/Reference.hxx:70
    11 com::sun::star::uno::Reference<com::sun::star::uno::XWeak>::query(com::sun::star::uno::BaseReference const&) (rRef=...) at include/com/sun/star/uno/Reference.hxx:371
    12 com::sun::star::uno::OWeakRefListener::OWeakRefListener(com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&) (this=0x603000e789b0, xInt=uno::Reference to ((anonymous namespace)::FactoryImpl *) 0x6080005aa620) at cppuhelper/source/weak.cxx:371
    13 com::sun::star::uno::WeakReferenceHelper::operator=(com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&) (this=0x7f3498ae06e0 <(anonymous namespace)::proxyfac_create(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&)::rwInstance>, xInt=uno::Reference to ((anonymous namespace)::FactoryImpl *) 0x6080005aa620) at cppuhelper/source/weak.cxx:500
    14 com::sun::star::uno::WeakReference<com::sun::star::uno::XInterface>::operator=(com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&) (this=0x7f3498ae06e0 <(anonymous namespace)::proxyfac_create(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&)::rwInstance>, xInt=uno::Reference to ((anonymous namespace)::FactoryImpl *) 0x6080005aa620) at include/cppuhelper/weakref.hxx:173
    15 (anonymous namespace)::proxyfac_create(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) () at stoc/source/proxy_factory/proxyfac.cxx:443
    16 cppu::OSingleFactoryHelper::createInstanceEveryTime(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x61000031cfa8, xContext=uno::Reference to (cppu::ComponentContext *) 0x611000003b50) at cppuhelper/source/factory.cxx:140
    17 cppu::OSingleFactoryHelper::createInstanceWithContext(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x61000031cfa8, xContext=uno::Reference to (cppu::ComponentContext *) 0x611000003b50) at cppuhelper/source/factory.cxx:175
    18 cppu::OFactoryComponentHelper::createInstanceWithContext(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x61000031cf40, xContext=uno::Reference to (cppu::ComponentContext *) 0x611000003b50) at cppuhelper/source/factory.cxx:378
    19 non-virtual thunk to cppu::OFactoryComponentHelper::createInstanceWithContext(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) () at cppuhelper/source/factory.cxx:364
    20 0x00007f34f0e6d166 in cppuhelper::ServiceManager::Data::Implementation::createInstance(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool) (this=0x60b000001850, context=uno::Reference to (cppu::ComponentContext *) 0x611000003b50, singletonRequest=false) at cppuhelper/source/servicemanager.cxx:668
    
    Change-Id: I8d10cca4965feb704c35c70cf99995be26e23a41
    (cherry picked from commit 7936368f9e7d0c50f7e3ebb987778029d0dcc22c)
    Reviewed-on: https://gerrit.libreoffice.org/41414
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/stoc/source/proxy_factory/proxyfac.cxx b/stoc/source/proxy_factory/proxyfac.cxx
index ea3c7479c21d..73fee1a05290 100644
--- a/stoc/source/proxy_factory/proxyfac.cxx
+++ b/stoc/source/proxy_factory/proxyfac.cxx
@@ -434,7 +434,10 @@ Reference< XInterface > SAL_CALL proxyfac_create(
 {
     Reference< XInterface > xRet;
     {
-    ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+    static osl::Mutex s_mutex;
+    // note: don't use ::osl::Mutex::getGlobalMutex() here, it deadlocks
+    //       with getImplHelperInitMutex()
+    ::osl::MutexGuard guard(s_mutex);
     static WeakReference < XInterface > rwInstance;
     xRet = rwInstance;
 


More information about the Libreoffice-commits mailing list