Bug 169711 - Crash on macOS when running LibreOffice headless via Terminal without GUI
Summary: Crash on macOS when running LibreOffice headless via Terminal without GUI
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
25.8.3.2 release
Hardware: ARM macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-27 16:14 UTC by Christian Schmitz
Modified: 2026-01-22 13:50 UTC (History)
3 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 Christian Schmitz 2025-11-27 16:14:55 UTC
Description:
When loading /Applications/LibreOffice.app/Contents/MacOS/soffice via script without being logged in for the GUI, the macOS process crashes.

As far as I see in the source code, the AquaSalInstance constructor creates some controls like a NSComboBox. But that triggers initialization of WMClientWindowManager, which calls an XPC connection to the window manager. That fails and the ap is killed.

Could LibreOffice be improved to see the "--headless" command line option early and then maybe not create windows/controls to avoid this?


Steps to Reproduce:
1.Login via Terminal to a user without GUI. Or login via ssh.
2.run soffice executable
3.it crashes

Actual Results:
crash with _xpc_api_misuse in the crash log.

Expected Results:
it works :-)


Reproducible: Always


User Profile Reset: Yes

Additional Info:
the crash report:

Process:               soffice [3694]
Path:                  /Applications/LibreOffice.app/Contents/MacOS/soffice
Identifier:            org.libreoffice.script
Version:               25.8.3.2 (25.8.3.2)
Code Type:             ARM-64 (Native)
Parent Process:        fmsased [2094]
Responsible:           fmserver_helperd [1901]
User ID:               502

Date/Time:             2025-11-27 15:11:51.7618 +0100
OS Version:            macOS 15.5 (24F74)
Report Version:        12
Anonymous UUID:        10EDCFAD-31C7-5E59-A421-416CEB1E8D21


Time Awake Since Boot: 1100 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: WMClientWindowManager

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x000000018f7bc77c

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [3694]

Application Specific Signatures:
API Misuse

Thread 0 Crashed::  Dispatch queue: WMClientWindowManager
0   libxpc.dylib                  	       0x18f7bc77c _xpc_api_misuse + 92
1   libxpc.dylib                  	       0x18f79a33c xpc_connection_set_target_uid + 216
2   WindowManagement              	       0x270b4ac58 -[WMClientWindowManager _createXPCConnection] + 1004
3   WindowManagement              	       0x270b4b834 -[WMClientWindowManager _xpcConnection] + 116
4   WindowManagement              	       0x270b48e48 __31-[WMClientWindowManager stages]_block_invoke + 36
5   libdispatch.dylib             	       0x18f8f485c _dispatch_client_callout + 16
6   libdispatch.dylib             	       0x18f8ea7a8 _dispatch_lane_barrier_sync_invoke_and_complete + 56
7   WindowManagement              	       0x270b48d90 -[WMClientWindowManager stages] + 300
8   AppKit                        	       0x1947c2734 __54-[NSWMWindowCoordinator initializeStageFramesIfNeeded]_block_invoke + 32
9   libdispatch.dylib             	       0x18f8f485c _dispatch_client_callout + 16
10  libdispatch.dylib             	       0x18f8dda28 _dispatch_once_callout + 32
11  AppKit                        	       0x1947c26e0 -[NSWMWindowCoordinator initializeStageFramesIfNeeded] + 304
12  AppKit                        	       0x193ab5aa8 -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 692
13  AppKit                        	       0x193ab5494 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 848
14  AppKit                        	       0x193ab5138 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
15  AppKit                        	       0x193d5c318 -[NSComboBoxWindow initWithContentRect:comboBoxCell:] + 88
16  AppKit                        	       0x193d5bd10 -[NSComboBoxCell initPopUpWindow] + 892
17  AppKit                        	       0x193dad2d4 -[NSComboBoxCell initTextCell:] + 100
18  libvclplug_osxlo.dylib        	       0x10501fd10 AquaSalInstance::AquaSalInstance() + 440
19  libvclplug_osxlo.dylib        	       0x10501fae8 create_SalInstance + 248
20  libmergedlo.dylib             	       0x10a72a02c (anonymous namespace)::tryInstance(rtl::OUString const&, bool) + 208
21  libmergedlo.dylib             	       0x10a729df4 CreateSalInstance() + 252
22  libmergedlo.dylib             	       0x10a779550 InitVCL() + 140
23  libmergedlo.dylib             	       0x10a779384 ImplSVMain() + 324
24  libmergedlo.dylib             	       0x1097b9504 soffice_main + 208
25  soffice                       	       0x10008851c main + 20
26  dyld                          	       0x18f6f2b98 start + 6076

PS: There is no user profile yet.
Comment 1 Christian Schmitz 2025-11-27 16:24:01 UTC
Call is e.g. 

/Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf --safe-mode --headless --nologo --safe-mode --outdir /tmp/test /tmp/test.docx

I added safe mode and no logo, but that didn't help.
Comment 2 Buovjaga 2025-11-29 05:46:08 UTC
I wonder, if a build with --enable-headless would help. Support for macOS was just added, see 5d4a689293d47c7671315452f6b90a185fe809c0 and other commits in the relation chain.
Comment 3 Hossein 2026-01-19 12:30:58 UTC
(In reply to Christian Schmitz from comment #1)
> Call is e.g. 
> 
> /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf
> --safe-mode --headless --nologo --safe-mode --outdir /tmp/test /tmp/test.docx
> 
> I added safe mode and no logo, but that didn't help.
The above command works fine for me over ssh to localhost, after enabling it in "System Preferences > Sharing > Remote Login" in macOS:

Version: 25.8.3.2 (AARCH64)
Build ID: 8ca8d55c161d602844f5428fa4b58097424e324e
CPU threads: 10; OS: macOS 26.2; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Also, for LibreOfficeDev, built without --enable-headless:

$ instdir/LibreOfficeDev.app/Contents/MacOS/soffice --convert-to pdf --safe-mode --headless --nologo --safe-mode --outdir /tmp/test /tmp/test.docx

Version: 26.8.0.0.alpha0+ (AARCH64)
Build ID: d0265596672d78ad6f3980ff6fb900535aefd11f
CPU threads: 10; OS: macOS 26.2; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

I used a very simple docx file with a few characters in it. Is it possible that you share the docx file? The crash can be related to that.
Comment 4 Christian Schmitz 2026-01-19 14:33:56 UTC
When you try to debug this, you need to run on macOS without GUI logged in.
Like login via ssh remotely to a Mac where nobody is logged in on the GUI.

Did you try that?

The crash happens way before any file is loaded.
The key thing is that some background GUI service is not running, so creating Cocoa controls fails.
Comment 5 Hossein 2026-01-22 05:47:32 UTC
(In reply to Christian Schmitz from comment #4)
> When you try to debug this, you need to run on macOS without GUI logged in.
> Like login via ssh remotely to a Mac where nobody is logged in on the GUI.
> 
> Did you try that?
Thanks for describing the problem in more detail. Previously I was testing with a user logged on.

But, now I tested in the scenario that you described, without logging in:

Latest LO 25.8 stable hangs (and not crashes):

Version: 25.8.3.2 (AARCH64)
Build ID: 8ca8d55c161d602844f5428fa4b58097424e324e
CPU threads: 10; OS: macOS 26.2; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Upon logging in, retrying the same command works as expected.

% /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf --safe-mode --headless --nologo --safe-mode --outdir /tmp/test /tmp/test.docx
soffice[59692:1326884] +[NSXPCSharedListener endpointForReply:withListenerName:replyErrorCode:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted

And it hangs at this point.

But latest LO 26.8 dev master compiled with --headless works fine.

% instdir/LibreOfficeDev.app/Contents/MacOS/soffice --convert-to pdf --safe-mode --headless --nologo --safe-mode --outdir /tmp/test /tmp/test.docx
Fontconfig warning: no <cachedir> elements found. Check configuration.
Fontconfig warning: adding <cachedir>/@.__________________________________________________OOO/var/cache/fontconfig</cachedir>
Fontconfig warning: adding <cachedir prefix="xdg">fontconfig</cachedir>
warn:writerfilter.dmapper:59748:1328413:sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx:1415: this should happen at a section context end
...
warn:legacy.osl:59748:1328413:oox/source/helper/storagebase.cxx:67: StorageBase::StorageBase - missing base input stream
convert /tmp/test.docx as a Writer document -> /private/tmp/test/test.pdf using filter : writer_pdf_Export
warn:vcl.schedule.deinit:59748:1328413:vcl/source/app/scheduler.cxx:181: DeInit task: Timer a: 1 p: 7 desktop::Desktop m_firstRunTimer 3000ms (0x16f853080) (ignored)
warn:vcl.schedule.deinit:59748:1328413:vcl/source/app/scheduler.cxx:202: DeInit active tasks: 1 (ignored: 1)
warn:sal.osl.pipe:59748:1328413:sal/osl/unx/pipe.cxx:354: shutdown() failed: ENOTCONN
warn:sal.osl.pipe:59748:1328420:sal/osl/unx/pipe.cxx:400: accept() failed: ECONNABORTED

I built LO again without --enable-headless to see the difference. The same hang happens in this case:

 % /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf --safe-mode --headless --nologo --safe-mode --outdir /tmp/test /tmp/test.docx
2026-01-22 06:44:42.009 soffice[51719:1540934] +[NSXPCSharedListener endpointForReply:withListenerName:replyErrorCode:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted

Hang happens here.

You may add the following configuration options, and test yourself with the latest sources:
https://wiki.documentfoundation.org/Development/BuildingOnMac

--enable-headless
--without-system-fontconfig
--without-system-freetype

Therefore, the problem seems to be fixed, and will be available once LibreOffice is shipped with headless mode enabled.

I will ask for adding --enable-headless in the futures builds, and then close this bug report as RESOLVED/FIXED, if there are no objections.
Comment 6 Christian Schmitz 2026-01-22 13:50:38 UTC
Thanks for testing.
I just tried 25.8.4.2 again.

This still calls 

16  AppKit                        	       0x19c89fd10 -[NSComboBoxCell initPopUpWindow] + 892
17  AppKit                        	       0x19c8f12d4 -[NSComboBoxCell initTextCell:] + 100
18  libvclplug_osxlo.dylib        	       0x1088a7f74 AquaSalInstance::AquaSalInstance() + 440
19  libvclplug_osxlo.dylib        	       0x1088a7d4c create_SalInstance + 248

even if I pass --headless, so maybe this version doesn't do it.

So I may wait for 26.8 being available.
If a nightly build or similar is available, I'd love to try it.