forms/source/component/DatabaseForm.cxx | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
New commits: commit df7cc4207d21641082e51230ba1903566bd153b3 Author: Noel Grandin <[email protected]> AuthorDate: Thu Sep 5 14:39:50 2024 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Wed Sep 11 11:07:07 2024 +0200 tsan:lock-order-inversion in forms ThreadSanitizer: lock-order-inversion (potential deadlock) Cycle in lock order graph: M0 (0x720c00011640) => M1 (0x720c00474120) => M0 Mutex M1 acquired here while holding mutex M0 in thread T8: 3 osl::Guard<osl::Mutex>::Guard(osl::Mutex&) 4 comphelper::OPropertySetAggregationHelper::setAggregation(com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&) ^^ acquires cppu mutex 5 frm::ODatabaseForm::impl_construct() 6 frm::ODatabaseForm::ODatabaseForm(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) 7 com_sun_star_comp_forms_ODatabaseForm_get_implementation 12 cppuhelper::ServiceManager::Data::Implementation::doCreateInstance(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) 13 cppuhelper::ServiceManager::Data::Implementation::createInstance(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool) 14 cppuhelper::ServiceManager::createInstanceWithContext(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) 15 cppuhelper::ServiceManager::createInstance(rtl::OUString const&) 16 non-virtual thunk to cppuhelper::ServiceManager::createInstance(rtl::OUString const&) 17 FmFormPageImpl::getDefaultForm() 18 FmFormPageImpl::findPlaceInFormComponentHierarchy(com::sun::star::uno::Reference<com::sun::star::form::XFormComponent> const&, com::sun::star::uno::Reference<com::sun::star::sdbc::XDataSource> const&, rtl::OUString const&, rtl::OUString const&, int) 19 FmXUndoEnvironment::Inserted(FmFormObj*) 20 FmXUndoEnvironment::Inserted(SdrObject*) 21 FmXUndoEnvironment::Notify(SfxBroadcaster&, SfxHint const&) 22 non-virtual thunk to FmXUndoEnvironment::Notify(SfxBroadcaster&, SfxHint const&) 23 SfxBroadcaster::Broadcast(SfxHint const&) 24 SdrObjList::InsertObject(SdrObject*, unsigned long) 25 FmFormPage::InsertObject(SdrObject*, unsigned long) 26 SvxDrawPage::add(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> const&) 27 SwFmDrawPage::add(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> const&) ^^ acquires solar mutex 28 non-virtual thunk to SwFmDrawPage::add(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> const&) 33 binaryurp::IncomingRequest::execute() const 35 cppu_threadpool::JobQueue::enter(void const*, bool) Mutex M0 acquired here while holding mutex M1 in thread T8: 6 SolarMutexClearableGuard::SolarMutexClearableGuard() 7 SfxModelGuard::SfxModelGuard(SfxBaseModel const&, SfxModelGuard::AllowedModelState) ^^ acquires solar mutex 8 SfxBaseModel::getArgs2(com::sun::star::uno::Sequence<rtl::OUString> const&) 9 SfxBaseModel::getArgs() 10 SwXTextDocument::getArgs() 11 non-virtual thunk to SwXTextDocument::getArgs() 12 dbtools::isEmbeddedInDatabase(com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&, com::sun::star::uno::Reference<com::sun::star::sdbc::XConnection>&) 13 frm::ODatabaseForm::setFastPropertyValue_NoBroadcast(int, com::sun::star::uno::Any const&) 15 cppu::OPropertySetHelper::setFastPropertyValue(int, com::sun::star::uno::Any const&) ^^ acquires cppu mutex 16 comphelper::OPropertySetAggregationHelper::setFastPropertyValue(int, com::sun::star::uno::Any const&) 17 cppu::OPropertySetHelper::setPropertyValue(rtl::OUString const&, com::sun::star::uno::Any const&) 18 non-virtual thunk to cppu::OPropertySetHelper::setPropertyValue(rtl::OUString const&, com::sun::star::uno::Any const&) 20 cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) /home/noel/libo-tsan/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:229 (libgcc3_uno.so+0x2118a) 22 binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny*, std::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) const 23 binaryurp::IncomingRequest::execute() const Change-Id: I00de2ad02b7ab247ee0aa62abcb11f5d46c9b157 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173067 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins (cherry picked from commit 07db23624497d303dca142ba9376cdcf265b20d8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173099 Reviewed-by: Michael Stahl <[email protected]> diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 118054615aa4..929d897e77a1 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -30,6 +30,7 @@ #include <property.hxx> #include <services.hxx> #include <comphelper/propertyvalue.hxx> +#include <comphelper/guarding.hxx> #include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/awt/XTextComponent.hpp> @@ -1643,10 +1644,14 @@ void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const A case PROPERTY_ID_DATASOURCE: { - Reference< XConnection > xSomeConnection; - if ( ::dbtools::isEmbeddedInDatabase( getParent(), xSomeConnection ) ) - throw PropertyVetoException(); - + css::uno::Reference<XInterface> xParent = getParent(); + { + // prevent ABBA deadlock between this mutex and the SolarMutex + comphelper::MutexRelease aReleaser(m_aMutex); + Reference< XConnection > xSomeConnection; + if ( ::dbtools::isEmbeddedInDatabase( xParent, xSomeConnection ) ) + throw PropertyVetoException(); + } try { m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCENAME, rValue); @@ -1709,8 +1714,15 @@ void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const A case PROPERTY_ID_ACTIVE_CONNECTION: { + bool bIsEmbeddedInDatabase; Reference< XConnection > xOuterConnection; - if ( ::dbtools::isEmbeddedInDatabase( getParent(), xOuterConnection ) ) + css::uno::Reference<XInterface> xParent = getParent(); + { + // prevent ABBA deadlock between this mutex and the SolarMutex + comphelper::MutexRelease aReleaser(m_aMutex); + bIsEmbeddedInDatabase = ::dbtools::isEmbeddedInDatabase( xParent, xOuterConnection ); + } + if (bIsEmbeddedInDatabase) { if ( xOuterConnection != Reference< XConnection >( rValue, UNO_QUERY ) ) // somebody's trying to set a connection which is not equal the connection
