Bug 167642 - Restart in safe mode doesn't launch safe mode on macOS
Summary: Restart in safe mode doesn't launch safe mode on macOS
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
26.2.0.0 alpha0+ master
Hardware: All macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:26.2.0
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-23 06:57 UTC by Telesto
Modified: 2025-07-25 12:20 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2025-07-23 06:57:13 UTC
Description:
Restart in safe mode doesn't launch safe mode on macOS

Steps to Reproduce:
1. Help -> Restart in safe-mode
2. Restart -> Nothing happens (or process silently quits)

Actual Results:
Safe-mode doesn't launch. 

Expected Results:
Safe-mode opens



Reproducible: Always


User Profile Reset: No

Additional Info:
Found in
Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 7f4868348c14b305fcd75744e1e3544d0d3a5d61
CPU threads: 8; OS: macOS 14.7.4; UI render: Skia/Metal; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded

Fine in
Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 7fddf33f70b5e496ca7e3936a845d47b9deca027
CPU threads: 8; OS: macOS 14.7.4; UI render: default; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded

I suspect it to be related to the mandatory skia rendering.  Safe-mode did use OSX
Comment 1 Patrick (volunteer) 2025-07-24 17:50:48 UTC
I can reproduce this in my local master build. LibreOffice is crashing on restart in the following code. In this case, the "image" variable is an invalid pointer.

frame #4: 0x0000000105657e20 libvcllo.dylib`SkiaSalGraphicsImpl::mergeCacheBitmaps(this=0x0000600001845300, bitmap=0x0000600001570f18, alphaBitmap=<unavailable>, targetSize=0x000000016fdfe150) at gdiimpl.cxx:1641:13
   1638	    if (const sk_sp<SkImage>& image = bitmap.GetSkImage(DirectImage::Yes))
   1639	    {
   1640	        assert(!bitmap.PreferSkShader());
-> 1641	        if (imageSize(image) == targetSize)
   1642	            bitmapReady = true;
   1643	    }
   1644	    // If the image usable and there's no alpha, then it matches exactly what's wanted.
(lldb) print image
(const sk_sp<SkImage> &) 0x0000600001570f88 (fPtr = 0x0000028400000018)

Below is the full stack:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x28400000038)
  * frame #0: 0x0000000105657e20 libvcllo.dylib`SkiaSalGraphicsImpl::mergeCacheBitmaps(SkiaSalBitmap const&, SkiaSalBitmap const*, Size const&) [inlined] SkISize::width(this=0x0000028400000038) const at SkSize.h:36:46
    frame #1: 0x0000000105657e20 libvcllo.dylib`SkiaSalGraphicsImpl::mergeCacheBitmaps(SkiaSalBitmap const&, SkiaSalBitmap const*, Size const&) [inlined] SkImageInfo::width(this=0x0000028400000028) const at SkImageInfo.h:371:44
    frame #2: 0x0000000105657e20 libvcllo.dylib`SkiaSalGraphicsImpl::mergeCacheBitmaps(SkiaSalBitmap const&, SkiaSalBitmap const*, Size const&) [inlined] SkImage::width(this=0x0000028400000018) const at SkImage.h:286:38
    frame #3: 0x0000000105657e20 libvcllo.dylib`SkiaSalGraphicsImpl::mergeCacheBitmaps(SkiaSalBitmap const&, SkiaSalBitmap const*, Size const&) [inlined] SkiaHelper::imageSize(image=<unavailable>) at utils.hxx:83:73
    frame #4: 0x0000000105657e20 libvcllo.dylib`SkiaSalGraphicsImpl::mergeCacheBitmaps(this=0x0000600001845300, bitmap=0x0000600001570f18, alphaBitmap=<unavailable>, targetSize=0x000000016fdfe150) at gdiimpl.cxx:1641:13
    frame #5: 0x0000000105658928 libvcllo.dylib`SkiaSalGraphicsImpl::drawAlphaBitmap(this=0x0000600001845300, rPosAry=0x000000016fdfe310, rSourceBitmap=0x0000600001570f18, rAlphaBitmap=0x0000600001570fb8) at gdiimpl.cxx:1835:11
    frame #6: 0x00000001052be90c libvcllo.dylib`OutputDevice::DrawDeviceAlphaBitmap(Bitmap const&, AlphaMask const&, Point const&, Size const&, Point const&, Size const&) + 456
    frame #7: 0x00000001052c04d0 libvcllo.dylib`OutputDevice::DrawBitmapEx(Point const&, Size const&, Point const&, Size const&, BitmapEx const&, MetaActionType) + 744
    frame #8: 0x00000001052c0178 libvcllo.dylib`OutputDevice::DrawBitmapEx(Point const&, BitmapEx const&) + 120
    frame #9: 0x000000010701b238 libspllo.dylib`(anonymous namespace)::SplashScreenWindow::Paint(OutputDevice&, tools::Rectangle const&) + 460
    frame #10: 0x000000010701c3e0 libspllo.dylib`(anonymous namespace)::SplashScreen::LinkStubAppEventListenerHdl(void*, VclSimpleEvent&) + 120
    frame #11: 0x00000001054dfc04 libvcllo.dylib`VclEventListeners::Call(VclSimpleEvent&) const + 308
    frame #12: 0x0000000105173728 libvcllo.dylib`vcl::Window::CallEventListeners(VclEventId, void*) + 120
    frame #13: 0x00000001051e74d8 libvcllo.dylib`vcl::Window::ImplSetReallyVisible() + 144
    frame #14: 0x00000001051e7548 libvcllo.dylib`vcl::Window::ImplSetReallyVisible() + 256
    frame #15: 0x00000001051ea240 libvcllo.dylib`vcl::Window::Show(bool, ShowFlags) + 1196
    frame #16: 0x00000001051ea2a0 libvcllo.dylib`vcl::Window::Show(bool, ShowFlags) + 1292
    frame #17: 0x000000010701a4d8 libspllo.dylib`(anonymous namespace)::SplashScreen::start(rtl::OUString const&, int) + 96
    frame #18: 0x000000010030af50 libsofficeapp.dylib`desktop::Desktop::OpenSplashScreen() + 1024
    frame #19: 0x000000010030a004 libsofficeapp.dylib`desktop::Desktop::Main() + 748
    frame #20: 0x00000001054d43f8 libvcllo.dylib`ImplSVMain() + 388
    frame #21: 0x000000010722043c libvclplug_osxlo.dylib`AquaSalInstance::handleAppDefinedEvent(NSEvent*) + 200
    frame #22: 0x000000010725715c libvclplug_osxlo.dylib`-[VCL_NSApplication sendEvent:] + 92
    frame #23: 0x000000019222042c AppKit`-[NSApplication _handleEvent:] + 60
    frame #24: 0x0000000191c76c8c AppKit`-[NSApplication run] + 520
    frame #25: 0x0000000191c4d35c AppKit`NSApplicationMain + 880
    frame #26: 0x0000000107222554 libvclplug_osxlo.dylib`AquaSalInstance::SVMainHook(int*) + 152
    frame #27: 0x00000001054d43d4 libvcllo.dylib`ImplSVMain() + 352
    frame #28: 0x0000000100333350 libsofficeapp.dylib`soffice_main + 208
    frame #29: 0x000000010000051c soffice`main + 20
    frame #30: 0x000000018d8d2b98 dyld`start + 6076
Comment 2 Patrick (volunteer) 2025-07-25 00:08:47 UTC
Found something. The bitmaps being passed are both not SkiaSalBitmap instances or invalid memory so I'll look further up the crash stack in comment #1:

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index bcc6cc01c0f0..c90cf2a1e770 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1740,6 +1740,7 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBi
     assert(dynamic_cast<const SkiaSalBitmap*>(&rAlphaBitmap));
     const SkiaSalBitmap& rSkiaSourceBitmap = static_cast<const SkiaSalBitmap&>(rSourceBitmap);
     const SkiaSalBitmap& rSkiaAlphaBitmap = static_cast<const SkiaSalBitmap&>(rAlphaBitmap);
+fprintf(stderr, "Here: %p %p\n", dynamic_cast<const SkiaSalBitmap*>(&rSourceBitmap), dynamic_cast<const SkiaSalBitmap*>(&rAlphaBitmap));
     // Use mergeCacheBitmaps(), which may decide to cache the result, avoiding repeated
     // alpha blending or scaling.
     SalTwoRect imagePosAry(rPosAry);
Comment 3 Patrick (volunteer) 2025-07-25 01:02:56 UTC
One more detail: the bug also occurs if you delete your LibreOffice preference files (e.g. instdir/LibreOfficeDev.app/Contents/user in a local build).
Comment 4 Noel Grandin 2025-07-25 06:16:06 UTC
fix is at https://gerrit.libreoffice.org/c/core/+/188313
Comment 5 Patrick (volunteer) 2025-07-25 11:17:57 UTC
The patch works in my local master build. I deleted my instdir/LibreOfficeDev.app/Contents/user folder and LibreOffice now launches and I am able to restart in safe mode and then restart in normal mode.
Comment 6 Commit Notification 2025-07-25 12:20:56 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e7bd446baa292b65c8b0141f404ce9b684b0abff

tdf#167642 Restart in safe mode doesn't launch safe mode on macOS

It will be available in 26.2.0.

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

Affected users are encouraged to test the fix and report feedback.