Bug Hunting Session
Bug 114025 - deadlock from lock dialog: Singleton vs. SolarMutex in framework
Summary: deadlock from lock dialog: Singleton vs. SolarMutex in framework
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
5.4.2.2 release
Hardware: All All
: high critical
Assignee: Not Assigned
URL:
Whiteboard: target:6.0.0 target:6.1.0 target:6.0....
Keywords:
: 109070 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-11-24 13:30 UTC by Michael Meeks
Modified: 2017-12-07 07:18 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
patch to help test the deadlock easily - finds another issue ... (2.62 KB, text/plain)
2017-11-24 14:40 UTC, Michael Meeks
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2017-11-24 13:30:09 UTC
I append an annotated stack trace that describes the issue.

Lets discuss the more general issue somewhere linked from here (if there is one) - I'd like to get this closed =)

(gdb) thread apply all backtrace

---Type <return> to continue, or q <return> to quit---
Thread 2 (Thread 0x7fc1dd47b700 (LWP 970)):
#0  0x00007fc1ffa0242d in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007fc1ff9fdde6 in _L_lock_870 () from /lib64/libpthread.so.0
#2  0x00007fc1ff9fdcdf in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00007fc201036680 in osl_acquireMutex (pMutex=<optimized out>)
    at /opt/collaboraoffice5.3/debugsource/sal/osl/unx/mutex.cxx:99
#4  0x00007fc2043a578d in SalYieldMutex::acquire() ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#5  0x00007fc202b62e71 in framework::HandlerCache::HandlerCache() ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#6  0x00007fc202b9ecfb in framework::DispatchProvider::DispatchProvider(com::sun::star::uno:---Type <return> to continue, or q <return> to quit---
:Reference<com::sun::star::uno::XComponentContext> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) () from /opt/collaboraoffice5.3/program/libmergedlo.so
#7  0x00007fc202c345dc in framework::Desktop::constructorInit() ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#8  0x00007fc202c3635b in com_sun_star_comp_framework_Desktop_get_implementation ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so

extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_framework_Desktop_get_implementation(
    css::uno::XComponentContext *context,
    css::uno::Sequence<css::uno::Any> const &)
{
    return cppu::acquire(Singleton::get(context).instance.get());
}

#9  0x00007fc1fb04cc0f in cppuhelper::ServiceManager::Data::Implementation::createInstance
    (this=0x2539e80, context=..., singletonRequest=singletonRequest@entry=false)
    at /opt/collaboraoffice5.3/debugsource/cppuhelper/source/servicemanager.cxx:693
#10 0x00007fc1fb050512 in cppuhelper::ServiceManager::createInstanceWithContext (
    this=<optimized out>, aServiceSpecifier=..., Context=...)
---Type <return> to continue, or q <return> to quit---
    at /opt/collaboraoffice5.3/debugsource/cppuhelper/source/servicemanager.cxx:1050

#11 0x00007fc1e7bd03cb in x11::SelectionManager::run(void*) ()
   from /opt/collaboraoffice5.3/program/libvclplug_genlo.so
#12 0x00007fc20103cc87 in osl_thread_start_Impl (pData=0x33fb5d0)
    at /opt/collaboraoffice5.3/debugsource/sal/osl/unx/thread.cxx:240
#13 0x00007fc1ff9fbe25 in start_thread () from /lib64/libpthread.so.0
#14 0x00007fc200d3234d in clone () from /lib64/libc.so.6

...

Thread 1 (Thread 0x7fc2062dca40 (LWP 961)):
#0  0x00007fc200d2c7f9 in syscall () from /lib64/libc.so.6
#1  0x00007fc1f965eeab in __cxa_guard_acquire () from /lib64/libstdc++.so.6
---Type <return> to continue, or q <return> to quit---
#2  0x00007fc202c3631c in com_sun_star_comp_framework_Desktop_get_implementation ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so

framework/source/services/desktop.cxx:

extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_framework_Desktop_get_implementation(
    css::uno::XComponentContext *context,
    css::uno::Sequence<css::uno::Any> const &)
{
    return cppu::acquire(Singleton::get(context).instance.get());
}

#3  0x00007fc1fb04cc0f in cppuhelper::ServiceManager::Data::Implementation::createInstance
    (this=0x2539e80, context=..., singletonRequest=singletonRequest@entry=false)
    at /opt/collaboraoffice5.3/debugsource/cppuhelper/source/servicemanager.cxx:693
#4  0x00007fc1fb050512 in cppuhelper::ServiceManager::createInstanceWithContext (
    this=<optimized out>, aServiceSpecifier=..., Context=...)
    at /opt/collaboraoffice5.3/debugsource/cppuhelper/source/servicemanager.cxx:1050
#5  0x00007fc202fd1359 in SfxApplication::Initialize_Impl() ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#6  0x00007fc202fc8d24 in SfxApplication::GetOrCreate() ()
---Type <return> to continue, or q <return> to quit---
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#7  0x00007fc203254232 in com_sun_star_comp_sfx2_GlobalEventBroadcaster_get_implementation
    () from /opt/collaboraoffice5.3/program/libmergedlo.so
#8  0x00007fc1fb04cc0f in cppuhelper::ServiceManager::Data::Implementation::createInstance
    (this=0x2560c40, context=..., singletonRequest=singletonRequest@entry=true)
    at /opt/collaboraoffice5.3/debugsource/cppuhelper/source/servicemanager.cxx:693
#9  0x00007fc1fb04dc21 in (anonymous namespace)::SingletonFactory::createInstanceWithContext (this=0x7fc2061da268, Context=...)
    at /opt/collaboraoffice5.3/debugsource/cppuhelper/source/servicemanager.cxx:535
#10 0x00007fc1faff63ed in cppu::ComponentContext::lookupMap (
    this=this@entry=0x7fc2061d5848, rName=...)
---Type <return> to continue, or q <return> to quit---
    at /opt/collaboraoffice5.3/debugsource/cppuhelper/source/component_context.cxx:330
#11 0x00007fc1faff8090 in cppu::ComponentContext::getValueByName (this=0x7fc2061d5848,
    rName=...)
    at /opt/collaboraoffice5.3/debugsource/cppuhelper/source/component_context.cxx:409
#12 0x00007fc204050ee9 in Dialog::Execute() ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so


+ must be this guy:

    + Holding the SolarMutex at this point.

    css::uno::Reference< css::uno::XComponentContext > xContext(
            comphelper::getProcessComponentContext() );
    css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_QUERY_THROW);
    css::document::DocumentEvent aObject;
    aObject.EventName = "DialogExecute";
    xEventBroadcaster->documentEventOccured(aObject);

#13 0x00007fc204071c2a in MessageDialog::Execute() ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so


#14 0x00007fc203313ddf in desktop::Lockfile_execWarning(desktop::Lockfile*) ()

desktop/source/app/lockfile2.cxx
	+ bool Lockfile_execWarning( Lockfile const * that )
   from /opt/collaboraoffice5.3/program/libmergedlo.so

#15 0x00007fc2028d91f9 in desktop::Lockfile::check(bool (*)(desktop::Lockfile*)) ()
---Type <return> to continue, or q <return> to quit---
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#16 0x00007fc2032fcfb1 in desktop::Desktop::Main() ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#17 0x00007fc2042f6626 in ImplSVMain() ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#18 0x00007fc2042f6712 in SVMain() () from /opt/collaboraoffice5.3/program/libmergedlo.so
#19 0x00007fc20331e37a in soffice_main ()
   from /opt/collaboraoffice5.3/program/libmergedlo.so
#20 0x000000000040075b in sal_main ()
    at /opt/collaboraoffice5.3/debugsource/desktop/source/app/main.c:48
#21 main (argc=<optimized out>, argv=<optimized out>)
---Type <return> to continue, or q <return> to quit---
    at /opt/collaboraoffice5.3/debugsource/desktop/source/app/main.c:47
(gdb)
Comment 1 Michael Meeks 2017-11-24 13:30:54 UTC
Symptoms are showing the 'lock' dialog and then hanging =) of course, only on some machines, just a race etc.
Comment 2 Stephan Bergmann 2017-11-24 13:53:56 UTC
sure, code calling out to UNO would need to do so with the SolarMutex not locked (just another example of how the SolarMutex is broken by design)

maybe it would work to make that framework::HandlerCache use a mutex of its own, instead of SolarMutex?
Comment 3 Michael Meeks 2017-11-24 14:40:23 UTC
Created attachment 137967 [details]
patch to help test the deadlock easily - finds another issue ...
Comment 4 Michael Meeks 2017-11-24 14:43:02 UTC
Of course, you fix one - and another one arrives:

>(gdb) bt
> #0  0x00007ffff73e98d7 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
> #1  0x00007ffff73eacaa in __GI_abort () at abort.c:78
> #2  0x00007ffff73e2866 in __assert_fail_base (fmt=0x7ffff751de40 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x7fffecd75ab0 "ImplGetSVData()->mpDefInst->GetYieldMutex()->IsCurrentThread() && \"SolarMutex not owned!\"", file=file@entry=0x7fffecd75a78 "/data/opt/libreoffice/master/vcl/source/app/dbggui.cxx", line=line@entry=47, function=function@entry=0x7fffecd76380 <ImplDbgTestSolarMutex()::__PRETTY_FUNCTION__> "void ImplDbgTestSolarMutex()") at assert.c:92
> #3  0x00007ffff73e2912 in __GI___assert_fail (assertion=0x7fffecd75ab0 "ImplGetSVData()->mpDefInst->GetYieldMutex()->IsCurrentThread() && \"SolarMutex not owned!\"", file=0x7fffecd75a78 "/data/opt/libreoffice/master/vcl/source/app/dbggui.cxx", line=47, function=0x7fffecd76380 <ImplDbgTestSolarMutex()::__PRETTY_FUNCTION__> "void ImplDbgTestSolarMutex()") at assert.c:101
> #4  0x00007fffec90d2ab in ImplDbgTestSolarMutex() () at /data/opt/libreoffice/master/vcl/source/app/dbggui.cxx:47
> #5  0x00007fffedc6835c in DbgTestSolarMutex() () at /data/opt/libreoffice/master/tools/source/debug/debug.cxx:73
> #6  0x00007ffff14d97f1 in SfxBroadcaster::AddListener(SfxListener&) (this=0x1ea24f0, rListener=...) at /data/opt/libreoffice/master/svl/source/notify/SfxBroadcaster.cxx:94
> #7  0x00007ffff14ecc0f in SfxListener::StartListening(SfxBroadcaster&, bool) (this=0x1e8a2e0, rBroadcaster=..., bPreventDuplicates=false) at /data/opt/libreoffice/master/svl/source/notify/lstner.cxx:106
> #8  0x00007ffff1c7e1cb in SfxPickListImpl::SfxPickListImpl(unsigned int) (this=0x1e8a2e0, nAllowedMenuSize=25) at /data/opt/libreoffice/master/sfx2/source/appl/sfxpicklist.cxx:201
> #9  0x00007ffff1c7df92 in SfxPickList::SfxPickList(unsigned int) (this=0x7ffff27f5790 <SfxPickList::ensure()::aUniqueInstance>, nAllowedMenuSize=25) at /data/opt/libreoffice/master/sfx2/source/appl/sfxpicklist.cxx:181
> #10 0x00007ffff1c7e09f in SfxPickList::ensure() () at /data/opt/libreoffice/master/sfx2/source/appl/sfxpicklist.cxx:193
> #11 0x00007ffff1bd92f9 in SfxApplication::Initialize_Impl() (this=0x1ea24f0) at /data/opt/libreoffice/master/sfx2/source/appl/appinit.cxx:223
> #12 0x00007ffff1bc1484 in SfxApplication::GetOrCreate() () at /data/opt/libreoffice/master/sfx2/source/appl/app.cxx:150
> #13 0x00007ffff1fdf091 in (anonymous namespace)::SfxGlobalEvents_Impl::SfxGlobalEvents_Impl(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x1d10cd0, rxContext=uno::Reference to (cppu::ComponentContext *) 0x7d9fb0) at /data/opt/libreoffice/master/sfx2/source/notify/globalevents.cxx:149
> #14 0x00007ffff1fe0a57 in (anonymous namespace)::Instance::Instance(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x7ffff27f6810 <_ZZN3rtl13StaticWithArgIN12_GLOBAL__N_18InstanceEN3com3sun4star3uno9ReferenceINS6_17XComponentContextEEENS1_9SingletonEE3getERKS9_E8instance>, context=uno::Reference to (cppu::ComponentContext *) 0x7d9fb0) at /data/opt/libreoffice/master/sfx2/source/notify/globalevents.cxx:422
> #15 0x00007ffff1fe0b61 in rtl::StaticWithArg<(anonymous namespace)::Instance, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>, (anonymous namespace)::Singleton>::get(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (rData=uno::Reference to (cppu::ComponentContext *) 0x7d9fb0) at /data/opt/libreoffice/master/include/rtl/instance.hxx:455
> #16 0x00007ffff1fe0ab7 in com_sun_star_comp_sfx2_GlobalEventBroadcaster_get_implementation(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) (context=0x7d9fb0) at /data/opt/libreoffice/master/sfx2/source/notify/globalevents.cxx:441
> #17 0x00007ffff3e83865 in std::_Function_handler<com::sun::star::uno::XInterface* (com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&), com::sun::star::uno::XInterface* (*)(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&)>::_M_invoke(std::_Any_data const&, com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) (__functor=..., __args#0=0x7d9fb0, __args#1=empty uno::Sequence) at /usr/include/c++/4.8/functional:2057
> #18 0x00007ffff3e77a59 in std::function<com::sun::star::uno::XInterface* (com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&)>::operator()(com::sun::star::uno::XComponentContext*, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) const (this=0x7412a0, __args#0=0x7d9fb0, __args#1=empty uno::Sequence) at /usr/include/c++/4.8/functional:2471
> #19 0x00007ffff3e672e3 in cppuhelper::ServiceManager::Data::Implementation::createInstance(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool) (this=0x741290, context=uno::Reference to (cppu::ComponentContext *) 0x7d9fb0, singletonRequest=true) at /data/opt/libreoffice/master/cppuhelper/source/servicemanager.cxx:665
> #20 0x00007ffff3e66959 in (anonymous namespace)::SingletonFactory::createInstanceWithContext(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x6d0210, Context=uno::Reference to (cppu::ComponentContext *) 0x7d9fb0) at /data/opt/libreoffice/master/cppuhelper/source/servicemanager.cxx:520
> #21 0x00007ffff3df7bb2 in cppu::ComponentContext::lookupMap(rtl::OUString const&) (this=0x7d9f60, rName="/singletons/com.sun.star.frame.theGlobalEventBroadcaster") at /data/opt/libreoffice/master/cppuhelper/source/component_context.cxx:305
> #22 0x00007ffff3df85a4 in cppu::ComponentContext::getValueByName(rtl::OUString const&) (this=0x7d9f60, rName="/singletons/com.sun.star.frame.theGlobalEventBroadcaster") at /data/opt/libreoffice/master/cppuhelper/source/component_context.cxx:381
> #23 0x00007fffec3eeb92 in com::sun::star::frame::theGlobalEventBroadcaster::get(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (the_context=uno::Reference to (cppu::ComponentContext *) 0x7d9fb0) at /data/opt/libreoffice/master/workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/frame/theGlobalEventBroadcaster.hpp:36
> #24 0x00007fffec3ecba1 in Dialog::Execute() (this=0x1985870) at /data/opt/libreoffice/master/vcl/source/window/dialog.cxx:1070
Comment 5 Commit Notification 2017-11-25 10:11:21 UTC
Michael Meeks committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4271a447cbc9f517e6cbd257790d08672f973b0a

tdf#114025 - minimal and not entirely convincing fix for assertion failure.

It will be available in 6.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2017-11-25 10:11:29 UTC
Michael Meeks committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b0e37303df56472fdc7782b977326c2391fdab07

tdf#114025 - avoid deadlock between x11 clipboard and the lock dialog.

It will be available in 6.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Michael Meeks 2017-11-25 10:13:18 UTC
Fixed, and cherry-picked to -5-4 too.
Comment 8 Commit Notification 2017-11-30 08:42:18 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=fa9c083c6071a0a4dc812f3c34731f347ddbabf7

tdf#114025 framework: avoid deadlock between Desktop init ...

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2017-11-30 21:46:44 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=95f643cd9c14f3eb8ca3a265d0d0ea8f4b7c8865&h=libreoffice-6-0

tdf#114025 framework: avoid deadlock between Desktop init ...

It will be available in 6.0.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2017-12-01 01:13:29 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0c528ae1589e5ce2c8780fcadeecdb4916395c25&h=libreoffice-5-4

tdf#114025 framework: avoid deadlock between Desktop init ...

It will be available in 5.4.4.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2017-12-01 12:29:13 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a246dc116a534cacef34c0e376a54391341b36e8

Revert "tdf#114025 - avoid deadlock between x11 clipboard and ...

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2017-12-02 15:02:07 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=eeab393fe392dd558beadb89ed7b1b541481b732&h=libreoffice-6-0

Revert "tdf#114025 - avoid deadlock between x11 clipboard and ...

It will be available in 6.0.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Aron Budea 2017-12-07 07:18:37 UTC
*** Bug 109070 has been marked as a duplicate of this bug. ***