[Libreoffice-commits] core.git: 3 commits - cppuhelper/source stoc/source
Michael Stahl
mstahl at redhat.com
Mon Aug 21 21:35:03 UTC 2017
cppuhelper/source/implbase_ex.cxx | 5 +++++
stoc/source/proxy_factory/proxyfac.cxx | 7 ++++---
2 files changed, 9 insertions(+), 3 deletions(-)
New commits:
commit eda41a271ed319560f0ab111cd9566266ab1bb29
Author: Michael Stahl <mstahl at redhat.com>
Date: Mon Aug 21 23:05:09 2017 +0200
cppuhelper: fix double checked locking in getTypeEntries()
Change-Id: I73674f0293a57ed7c4d54aa6b68ff64d5ca4e7bd
diff --git a/cppuhelper/source/implbase_ex.cxx b/cppuhelper/source/implbase_ex.cxx
index 2b7b792e718a..d01f61983a91 100644
--- a/cppuhelper/source/implbase_ex.cxx
+++ b/cppuhelper/source/implbase_ex.cxx
@@ -105,9 +105,14 @@ static inline type_entry * getTypeEntries( class_data * cd )
// ref is statically held by getCppuType()
pEntry->m_type.typeRef = rType.getTypeLibType();
}
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
cd->m_storedTypeRefs = true;
}
}
+ else
+ {
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ }
return pEntries;
}
commit 20a7ffd848ee9d9007ae1c9464713f9d1d125bce
Author: Michael Stahl <mstahl at redhat.com>
Date: Mon Aug 21 22:54:33 2017 +0200
stoc: remove extra braces
Change-Id: I3b6b77ba58832d7bfc350eeb5e589513b716a081
diff --git a/stoc/source/proxy_factory/proxyfac.cxx b/stoc/source/proxy_factory/proxyfac.cxx
index 49f380e86d0d..ae2c94f3c426 100644
--- a/stoc/source/proxy_factory/proxyfac.cxx
+++ b/stoc/source/proxy_factory/proxyfac.cxx
@@ -432,7 +432,6 @@ Reference< XInterface > SAL_CALL proxyfac_create(
SAL_UNUSED_PARAMETER Reference< XComponentContext > const & )
{
Reference< XInterface > xRet;
- {
static osl::Mutex s_mutex;
// note: don't use ::osl::Mutex::getGlobalMutex() here, it deadlocks
// with getImplHelperInitMutex()
@@ -445,7 +444,6 @@ Reference< XInterface > SAL_CALL proxyfac_create(
xRet = static_cast< ::cppu::OWeakObject * >(new FactoryImpl);
rwInstance = xRet;
}
- }
return xRet;
}
commit 7936368f9e7d0c50f7e3ebb987778029d0dcc22c
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
diff --git a/stoc/source/proxy_factory/proxyfac.cxx b/stoc/source/proxy_factory/proxyfac.cxx
index ed33ea63f642..49f380e86d0d 100644
--- a/stoc/source/proxy_factory/proxyfac.cxx
+++ b/stoc/source/proxy_factory/proxyfac.cxx
@@ -433,7 +433,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