Description
Bug summary
When the macOS backend is used to draw a figure in Ventura (I am on 13.4.1), it crashes with an XPC misuse error when it is run from a non-root and non-logged-in user (from what I can tell).
...
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000181f5db40
Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process: exc handler [35989]
Application Specific Signatures:
API Misuse
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libxpc.dylib 0x181f5db40 _xpc_api_misuse + 92
1 libxpc.dylib 0x181f3fb2c xpc_connection_set_target_uid + 216
2 WindowManagement 0x208de9cf0 -[WMClientWindowManager _createXPCConnection] + 968
3 WindowManagement 0x208dea630 -[WMClientWindowManager _xpcConnection] + 172
4 WindowManagement 0x208de83f0 -[WMClientWindowManager stages] + 84
5 AppKit 0x185e5e568 __54-[NSWMWindowCoordinator initializeStageFramesIfNeeded]_block_invoke + 32
6 libdispatch.dylib 0x18204c400 _dispatch_client_callout + 20
7 libdispatch.dylib 0x18204dc40 _dispatch_once_callout + 32
8 AppKit 0x185e5e514 -[NSWMWindowCoordinator initializeStageFramesIfNeeded] + 304
9 AppKit 0x18550b278 -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 660
10 AppKit 0x18550ac50 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 684
11 AppKit 0x18550a998 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
12 ??? 0x118de0980 -[Window initWithContentRect:styleMask:backing:defer:withManager:] + 68
13 ??? 0x118de3f74 FigureManager_init + 240
14 ??? 0x101106744 wrap_init + 20
15 ??? 0x1010a735c wrapperdescr_call + 392
16 ??? 0x10109e400 _PyObject_MakeTpCall + 360
...
Code for reproduction
N/A
Actual outcome
N/A
Expected outcome
N/A
Additional information
The most common place I have seen this is when a module consuming matplotlib draws figures in its tests without specifying a backend. When that module is built by the nix package manager, the build is performed by a non-root, non-logged-in user, triggering this crash.
I do not think there is anything actionable here but wanted to open an issue to help anyone else who runs into this. Perhaps detection is possible during backend selection, but it's not entirely obvious to me how to do it robustly. If the team agrees, we can close this issue.
Operating system
macOS 13.4.1
Matplotlib Version
3.7.1
Matplotlib Backend
macosx
Python version
3.10.11
Jupyter version
No response
Installation
None