[Libreoffice-commits] core.git: dbaccess/source

Michael Stahl mstahl at redhat.com
Thu Aug 24 11:08:40 UTC 2017


 dbaccess/source/core/dataaccess/databasecontext.cxx |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit a05e5adc62c74b42262fce9a309c1bc6c685893c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Aug 24 12:41:24 2017 +0200

    dbaccess: avoid deadlock in ODatabaseContext::registerObject()
    
    Limit the scope of m_aMutex lock to what is necessary.
    
    As observed by Jan-Marek Glogowski:
    
    [Switching to thread 198 (Thread 0x2aab44e5b700 (LWP 46847))]
    3  osl_acquireMutex(oslMutexImpl*) (pMutex=0x1e59d10) at sal/osl/unx/mutex.cxx:97
    4  osl::Mutex::acquire() (this=0x1ebbe28) at include/osl/mutex.hxx:56
    5  osl::Guard<osl::Mutex>::Guard(osl::Mutex&, bool) (this=0x2aab44e56198, rT=..., bAquire=true) at include/osl/mutex.hxx:135
    6  dbaccess::ODatabaseContext::getElementNames() (this=0x1ebbd90) at dbaccess/source/core/dataaccess/databasecontext.cxx:661
    7  non-virtual thunk to dbaccess::ODatabaseContext::getElementNames() () at dbaccess/source/core/dataaccess/databasecontext.cxx:659
    8  dbaui::SbaTableQueryBrowser::initializeTreeModel() (this=0xb174890) at dbaccess/source/ui/browser/unodatbr.cxx:2086
    9  dbaui::SbaTableQueryBrowser::impl_initialize() (this=0xb174890) at dbaccess/source/ui/browser/unodatbr.cxx:3201
    10 dbaui::OGenericUnoController::initialize(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) (this=0xb174890, aArguments=uno::Sequence of length 9 = {...}) at dbaccess/source/ui/browser/genericcontroller.cxx:299
    11 DBContentLoader::load(com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XLoadEventListener> const&) (this=0xb1730a0, rFrame=uno::Reference to ((anonymous namespace)::Frame *) 0xb162690, rURL=".component:DB/DataSourceBrowser", rArgs=uno::Sequence of length 8 = {...}, rListener=uno::Reference to (framework::LoadEnvListener *) 0xb174228) at dbaccess/source/ui/browser/dbloader.cxx:270
    12 framework::LoadEnv::impl_loadContent() (this=0xb16f5b8) at framework/source/loadenv/loadenv.cxx:1077
    13 framework::LoadEnv::startLoading() (this=0xb16f5b8) at framework/source/loadenv/loadenv.cxx:372
    
    [Switching to thread 196 (Thread 0x2aab4565f700 (LWP 42841))]
    3  osl_acquireMutex(oslMutexImpl*) (pMutex=0x773cd0) at sal/osl/unx/mutex.cxx:97
    4  osl::Mutex::acquire() (this=0x77b4a8) at include/osl/mutex.hxx:56
    5  comphelper::GenericSolarMutex::doAcquire(unsigned int) (this=0x77b4a0, nLockCount=1) at comphelper/source/misc/solarmutex.cxx:61
    6  comphelper::SolarMutex::acquire(unsigned int) (this=0x77b4a0, nLockCount=1) at include/comphelper/solarmutex.hxx:74
    7  osl::ClearableGuard<comphelper::SolarMutex>::ClearableGuard(comphelper::SolarMutex&) (this=0x2aab4565d478, t=...) at include/osl/mutex.hxx:170
    8  osl::ResettableGuard<comphelper::SolarMutex>::ResettableGuard(comphelper::SolarMutex&) (this=0x2aab4565d478, rT=...) at include/osl/mutex.hxx:215
    9  SolarMutexResettableGuard::SolarMutexResettableGuard() (this=0x2aab4565d478) at include/vcl/svapp.hxx:1416
    10 dbaccess::ModelMethodGuard::ModelMethodGuard(dbaccess::ModelDependentComponent const&) (this=0x2aab4565d478, _component=...) at dbaccess/source/core/dataaccess/ModelImpl.hxx:587
    11 dbaccess::ODatabaseSource::getDatabaseDocument() (this=0x281d690) at dbaccess/source/core/dataaccess/datasource.cxx:1300
    12 non-virtual thunk to dbaccess::ODatabaseSource::getDatabaseDocument() () at dbaccess/source/core/dataaccess/datasource.cxx:1298
    13 dbaccess::ODatabaseContext::registerObject(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&) (this=0x1ebbd90, _rName="MyFactory", _rxObject=uno::Reference to (dbaccess::ODatabaseSource *) 0x281d708) at dbaccess/source/core/dataaccess/databasecontext.cxx:433
    14 gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) (pThis=0x1ebbdf8, nVtableIndex=4, pRegisterReturn=0x0, pReturnTypeRef=0x781090, bSimpleReturn=true, pStack=0x2aab4565d810, nStack=0, pGPR=0x2aab4565db30, pFPR=0x2aab4565daf0) at bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:77
    
    Change-Id: I06e91d9c4e193c97f98f29f6b73eaf01b12922c0

diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx
index e023806270b2..4d2305a6b9cf 100644
--- a/dbaccess/source/core/dataaccess/databasecontext.cxx
+++ b/dbaccess/source/core/dataaccess/databasecontext.cxx
@@ -423,9 +423,6 @@ void ODatabaseContext::setTransientProperties(const OUString& _sURL, ODatabaseMo
 
 void ODatabaseContext::registerObject(const OUString& _rName, const Reference< XInterface > & _rxObject)
 {
-    MutexGuard aGuard(m_aMutex);
-    ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
-
     if ( _rName.isEmpty() )
         throw IllegalArgumentException( OUString(), *this, 1 );
 
@@ -438,9 +435,14 @@ void ODatabaseContext::registerObject(const OUString& _rName, const Reference< X
     if ( sURL.isEmpty() )
         throw IllegalArgumentException( DBA_RES( RID_STR_DATASOURCE_NOT_STORED ), *this, 2 );
 
-    registerDatabaseLocation( _rName, sURL );
+    { // avoid deadlocks: lock m_aMutex after checking arguments
+        MutexGuard aGuard(m_aMutex);
+        ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
 
-    ODatabaseSource::setName( xDocDataSource, _rName, ODatabaseSource::DBContextAccess() );
+        registerDatabaseLocation( _rName, sURL );
+
+        ODatabaseSource::setName( xDocDataSource, _rName, ODatabaseSource::DBContextAccess() );
+    }
 
     // notify our container listeners
     ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rName), makeAny(_rxObject), Any());


More information about the Libreoffice-commits mailing list