summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2018-02-19 13:16:07 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-02-20 12:46:36 +0100
commit854d5f0f4f4f61d559305befa1daf2721b3d4ee6 (patch)
tree6f7d4f5a946efd3514d8a125add73e88c1d7fae8 /svx/source
parent2e06dfb831a93b8207cc4e0f43221ef5eeb1853b (diff)
svx: fix deadlock in Gallery::GetGalleryInstance()
Seen in UITest_writer_tests. Use C++11 thread-safe static initialisation here, which should avoid the deadlock that is caused by relying on osl::Mutex::getGlobalMutex(). Thread #1: 2 in osl_acquireMutex(oslMutexImpl*) (pMutex=0x1ad2c70) at sal/osl/unx/mutex.cxx:97 3 in osl::Mutex::acquire() (this=0x7ff3252b9628 <rtl::Static<osl::Mutex, (anonymous namespace)::theImplHelperInitMutex>::get()::instance>) at include/osl/mutex.hxx:56 4 in osl::Guard<osl::Mutex>::Guard(osl::Mutex&) (this=0x7ffca8bdd6c0, t=...) at include/osl/mutex.hxx:129 5 in cppu::getTypeEntries(cppu::class_data*) (cd=0x7ff31e458fe0 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::io::XActiveDataControl, com::sun::star::io::XActiveDataSink>, com::sun::star::io::XActiveDataControl, com::sun::star::io::XActiveDataSink>::operator()()::s_cd>) at cppuhelper/source/implbase_ex.cxx:89 6 in cppu::queryDeepNoXInterface(typelib_TypeDescriptionReference const*, cppu::class_data*, void*) (pDemandedTDR=0x2e643b0, cd=0x7ff31e458fe0 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::io::XActiveDataControl, com::sun::star::io::XActiveDataSink>, com::sun::star::io::XActiveDataControl, com::sun::star::io::XActiveDataSink>::operator()()::s_cd>, that=0x387cbe0) at cppuhelper/source/implbase_ex.cxx:173 [...] 20 in utl::UcbStreamHelper::CreateStream(rtl::OUString const&, StreamMode) (rFileName="file://instdir/program/../share/gallery/sounds.thm", eOpenMode=StreamMode::READ) at unotools/source/ucbhelper/ucbstreamhelper.cxx:149 21 in GalleryTheme::CreateThemeEntry(INetURLObject const&, bool) (rURL=..., bReadOnly=false) at svx/source/gallery2/galtheme.cxx:692 22 in Gallery::ImplLoadSubDirs(INetURLObject const&, bool&) (this=0x38762c0, rBaseURL=..., rbDirIsReadOnly=@0x7ffca8bde7df: false) at svx/source/gallery2/gallery1.cxx:474 23 in Gallery::ImplLoad(rtl::OUString const&) (this=0x38762c0, rMultiPath="file://instdir/program/../share/gallery;file://workdir/UITest/writer_tests/user/user/gallery") at svx/source/gallery2/gallery1.cxx:301 24 in Gallery::Gallery(rtl::OUString const&) (this=0x38762c0, rMultiPath="file://instdir/program/../share/gallery;file://workdir/UITest/writer_tests/user/user/gallery") at svx/source/gallery2/gallery1.cxx:257 25 in Gallery::GetGalleryInstance() () at svx/source/gallery2/gallery1.cxx:273 26 in GalleryExplorer::BeginLocking(unsigned int) (nThemeId=3) at svx/source/gallery2/galexpl.cxx:264 27 in SvxBmpNumValueSet::init() (this=0x3873ed0) at svx/source/dialog/svxbmpnumvalueset.cxx:501 Thread #8 Grammar Checking: 2 in osl_acquireMutex(oslMutexImpl*) (pMutex=0x7ff329045420 <globalMutexImpl>) at sal/osl/unx/mutex.cxx:97 3 in osl::Mutex::acquire() (this=0x7ff32903b780 <osl_getGlobalMutex::globalMutex>) at include/osl/mutex.hxx:56 4 in osl::Guard<osl::Mutex>::Guard(osl::Mutex*) (this=0x7ff2f5b30030, pT_=0x7ff32903b780 <osl_getGlobalMutex::globalMutex>) at include/osl/mutex.hxx:122 5 in com::sun::star::container::cppu_detail_getUnoType(com::sun::star::container::XEnumeration const*) () at workdir/UnoApiHeadersTarget/udkapi/comprehensive/com/sun/star/container/XEnumeration.hpp:69 6 in cppu::UnoType<com::sun::star::container::XEnumeration>::get() () at include/cppu/unotype.hxx:296 7 in cppu::detail::cppu_detail_getUnoType<com::sun::star::container::XEnumeration>(com::sun::star::uno::Reference<com::sun::star::container::XEnumeration> const*) () at include/cppu/unotype.hxx:259 8 in cppu::UnoType<com::sun::star::uno::Reference<com::sun::star::container::XEnumeration> >::get() () at include/cppu/unotype.hxx:296 9 in com::sun::star::reflection::detail::theXTypeDescriptionEnumerationType::operator()() const (this=0x7ff2f5b30177) at workdir/UnoApiHeadersTarget/udkapi/comprehensive/com/sun/star/reflection/XTypeDescriptionEnumeration.hpp:30 10 in rtl::StaticWithInit<com::sun::star::uno::Type*, com::sun::star::reflection::detail::theXTypeDescriptionEnumerationType, com::sun::star::reflection::detail::theXTypeDescriptionEnumerationType, com::sun::star::uno::Type*>::get() () at include/rtl/instance.hxx:603 11 in com::sun::star::reflection::cppu_detail_getUnoType(com::sun::star::reflection::XTypeDescriptionEnumeration const*) () at workdir/UnoApiHeadersTarget/udkapi/comprehensive/com/sun/star/reflection/XTypeDescriptionEnumeration.hpp:57 12 in cppu::UnoType<com::sun::star::reflection::XTypeDescriptionEnumeration>::get() () at include/cppu/unotype.hxx:296 13 in com::sun::star::reflection::XTypeDescriptionEnumeration::static_type(void*) () at workdir/UnoApiHeadersTarget/udkapi/comprehensive/com/sun/star/reflection/XTypeDescriptionEnumeration.hpp:102 14 in cppu::getTypeEntries(cppu::class_data*) (cd=0x7ff3252b8ac0 <cppu::detail::ImplClassData<cppu::WeakImplHelper<com::sun::star::reflection::XTypeDescriptionEnumeration>, com::sun::star::reflection::XTypeDescriptionEnumeration>::operator()()::s_cd>) at cppuhelper/source/implbase_ex.cxx:96 Change-Id: I3aa3167ca8989b3d6be053e1c97f3b7a64bfbfb8 Reviewed-on: https://gerrit.libreoffice.org/49986 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 713ac313c1f053cc5d812843a3b5611f7d1a10e5) Reviewed-on: https://gerrit.libreoffice.org/50030 Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/gallery2/gallery1.cxx14
1 files changed, 4 insertions, 10 deletions
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index d89d896946af..d61b045b8a71 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -267,16 +267,10 @@ Gallery::~Gallery()
Gallery* Gallery::GetGalleryInstance()
{
- static Gallery* s_pGallery = nullptr;
-
- if (!s_pGallery)
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if (!s_pGallery && !utl::ConfigManager::IsFuzzing())
- {
- s_pGallery = new Gallery( SvtPathOptions().GetGalleryPath() );
- }
- }
+ // note: this would deadlock if it used osl::Mutex::getGlobalMutex()
+ static Gallery *const s_pGallery(
+ utl::ConfigManager::IsFuzzing() ? nullptr :
+ new Gallery(SvtPathOptions().GetGalleryPath()));
return s_pGallery;
}