[Libreoffice-commits] core.git: vcl/osx
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 19 22:17:53 UTC 2021
vcl/osx/salmenu.cxx | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 6ee7a3b2c0565c2871d32d704cb2899445b9f88d
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Jan 19 17:31:46 2021 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Jan 19 23:17:10 2021 +0100
Avoid deadlock when macOS menu-related code is run on non-main thread
At least on macOS 11.1 on ARM64 (though not with an otherwise somewhat similar
build on macOS 10.15.7 on x86-64), CppunitTest_smoketest deadlocked the soffice
process for me, first while processing a remote call from cppunittester at
> thread #8, name = 'cppu_threadpool::ORequestThread'
> frame #0: 0x0000000183c43488 libsystem_kernel.dylib`__psynch_cvwait + 8
> frame #1: 0x0000000183c79568 libsystem_pthread.dylib`_pthread_cond_wait + 1192
> frame #2: 0x0000000184aeb0f0 Foundation`-[NSOperation waitUntilFinished] + 584
> frame #3: 0x0000000183d370e0 CoreFoundation`_CFXNotificationPost + 800
> frame #4: 0x0000000184aa0650 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 64
> frame #5: 0x000000018653d3bc AppKit`-[NSMenu insertItem:atIndex:] + 624
> frame #6: 0x000000018653e66c AppKit`-[NSMenu insertItemWithTitle:action:keyEquivalent:atIndex:] + 144
> frame #7: 0x0000000115d16a28 libvclplug_osxlo.dylib`initAppMenu() at vcl/osx/salmenu.cxx:126:16
> frame #8: 0x0000000115d1691c libvclplug_osxlo.dylib`AquaSalInstance::CreateMenu(this=0x000000013febbd10, bMenuBar=false, pVCLMenu=0x0000000299db67a0) at vcl/osx/salmenu.cxx:207:5
> frame #9: 0x000000010b1b8620 libvcllo.dylib`PopupMenu::PopupMenu(this=0x0000000299db67a0) at vcl/source/window/menu.cxx:2718:45
[...]
and later while processing a remote call from cppunittester at
> thread #8, name = 'cppu_threadpool::ORequestThread'
> frame #0: 0x0000000183c43488 libsystem_kernel.dylib`__psynch_cvwait + 8
> frame #1: 0x0000000183c79568 libsystem_pthread.dylib`_pthread_cond_wait + 1192
> frame #2: 0x0000000184aeb0f0 Foundation`-[NSOperation waitUntilFinished] + 584
> frame #3: 0x0000000183d370e0 CoreFoundation`_CFXNotificationPost + 800
> frame #4: 0x0000000184aa0650 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 64
> frame #5: 0x000000018653d3bc AppKit`-[NSMenu insertItem:atIndex:] + 624
> frame #6: 0x0000000119858590 libvclplug_osxlo.dylib`AquaSalMenu::InsertItem(this=0x000000028be8cc20, pSalMenuItem=0x000000028be67420, nPos=65535) at vcl/osx/salmenu.cxx:489:9
> frame #7: 0x000000010aa8a424 libvcllo.dylib`Menu::NbcInsertItem(this=0x000000028be78f90, nId=2, nBits=NONE, rStr=0x000000028070ef70, pMenu=0x000000028be78f90, nPos=65535, rIdent=0x000000028070ef10) at vcl/source/window/menu.cxx:416:27
[...]
and the main thread in both cases in the main loop at
> thread #1, queue = 'com.apple.main-thread'
> frame #0: 0x0000000183c43488 libsystem_kernel.dylib`__psynch_cvwait + 8
> frame #1: 0x0000000183c79568 libsystem_pthread.dylib`_pthread_cond_wait + 1192
> frame #2: 0x00000001013b0354 libc++.1.0.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) [inlined] std::__1::__libcpp_condvar_wait(__cv=<unavailable>, __m=<unavailable>) at ~/llvm/build/include/c++/v1/__threading_support:436:10 [opt]
> frame #3: 0x00000001013b0350 libc++.1.0.dylib`std::__1::condition_variable::wait(this=<unavailable>, lk=<unavailable>) at ~/github.com/llvm/llvm-project/libcxx/src/condition_variable.cpp:44 [opt]
> frame #4: 0x0000000115d0a8fc libvclplug_osxlo.dylib`void std::__1::condition_variable::wait<SalYieldMutex::doAcquire(unsigned int)::$_0>(this=0x000000013fec8f50, __lk=0x000000016f255bf8, __pred=(anonymous class) @ 0x000000016f255b80)::$_0) at ~/llvm/inst/include/c++/v1/__mutex_base:406:9
> frame #5: 0x0000000115d0a71c libvclplug_osxlo.dylib`SalYieldMutex::doAcquire(this=0x000000013fec8ef0, nLockCount=1) at vcl/osx/salinst.cxx:215:36
> frame #6: 0x000000010b15ec90 libvcllo.dylib`comphelper::SolarMutex::acquire(this=0x000000013fec8ef0, nLockCount=1) at include/comphelper/solarmutex.hxx:86:5
> frame #7: 0x000000010b8215c4 libvcllo.dylib`SalInstance::AcquireYieldMutex(this=0x000000013febbd10, nCount=1) at vcl/source/app/salvtables.cxx:121:73
> frame #8: 0x000000010b8c1d78 libvcllo.dylib`Application::AcquireSolarMutex(nCount=1) at vcl/source/app/svapp.cxx:562:25
> frame #9: 0x0000000115d10000 libvclplug_osxlo.dylib`SolarMutexReleaser::~SolarMutexReleaser(this=0x000000016f255e28) at include/vcl/svapp.hxx:1421:29
> frame #10: 0x0000000115d0c650 libvclplug_osxlo.dylib`SolarMutexReleaser::~SolarMutexReleaser(this=0x000000016f255e28) at include/vcl/svapp.hxx:1421:27
> frame #11: 0x0000000115d0c2d8 libvclplug_osxlo.dylib`AquaSalInstance::DoYield(this=0x000000013febbd10, bWait=true, bHandleAllCurrentEvents=false) at vcl/osx/salinst.cxx:570:9
> frame #12: 0x000000010b8c1558 libvcllo.dylib`ImplYield(i_bWait=true, i_bAllEvents=false) at core/vcl/source/app/svapp.cxx:463:48
> frame #13: 0x000000010b8c1298 libvcllo.dylib`Application::Yield() at vcl/source/app/svapp.cxx:528:5
> frame #14: 0x000000010b8c120c libvcllo.dylib`Application::Execute() at vcl/source/app/svapp.cxx:442:9
[...]
Change-Id: I5146b7bdeb6b1b9b9ad4f4b91bbe52de0b76f308
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109648
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx
index 80752b0c05ce..eb5df0b308c0 100644
--- a/vcl/osx/salmenu.cxx
+++ b/vcl/osx/salmenu.cxx
@@ -31,6 +31,7 @@
#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
+#include <osx/runinmain.hxx>
#include <osx/saldata.hxx>
#include <osx/salinst.h>
#include <osx/salmenu.h>
@@ -117,6 +118,7 @@ static void initAppMenu()
static bool bInitialized = false;
if (bInitialized)
return;
+ OSX_SALDATA_RUNINMAIN(initAppMenu())
bInitialized = true;
NSMenu* pAppMenu = nil;
@@ -463,6 +465,8 @@ void AquaSalMenu::SetFrame( const SalFrame *pFrame )
void AquaSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos )
{
+ OSX_SALDATA_RUNINMAIN(InsertItem(pSalMenuItem, nPos))
+
AquaSalMenuItem *pAquaSalMenuItem = static_cast<AquaSalMenuItem*>(pSalMenuItem);
pAquaSalMenuItem->mpParentMenu = this;
More information about the Libreoffice-commits
mailing list