Kaydet (Commit) a05e5adc authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 74da6d5f
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment