Skip to content

skip PythonProcess preimport on macOS#37506

Open
utkarshgill wants to merge 1 commit intocommaai:masterfrom
utkarshgill:fix/macos-sim-startup
Open

skip PythonProcess preimport on macOS#37506
utkarshgill wants to merge 1 commit intocommaai:masterfrom
utkarshgill:fix/macos-sim-startup

Conversation

@utkarshgill
Copy link
Contributor

@utkarshgill utkarshgill commented Mar 1, 2026

Fixes #37504

manager.py module-level imports create OS threads (sentry) before unblock_stdout() calls
os.forkpty(). The forkpty child -- which never exec's -- then runs prepare(), which
preimports selfdrive.ui.ui → raylib → CoreFoundation. macOS kills the child (SIGSEGV)
because CoreFoundation was initialized inside a fork-without-exec of a multi-threaded process.

This skips preimport on Darwin. Modules are still imported normally when each child starts
via multiprocessing spawn (fork+exec → fresh interpreter). Only startup speed is affected
on macOS, no functional change on Linux.

OBJC_DISABLE_INITIALIZE_FORK_SAFETY doesn't work on macOS 14+. A full fix would be
reworking unblock_stdout() to avoid forkpty on macOS, but that's a bigger change.

@utkarshgill utkarshgill force-pushed the fix/macos-sim-startup branch from 839c25f to fcab9e0 Compare March 2, 2026 05:25
…rk crash

PythonProcess.prepare() preimports modules like selfdrive.ui.ui, which
loads raylib and initializes CoreFoundation. When the manager subsequently
forks child processes, macOS detects CoreFoundation was active pre-fork
and crashes every child with "You MUST exec()". The process exits in ~1.5s.

Skip preimporting on Darwin. Modules are still imported normally when
each child process starts.
@utkarshgill utkarshgill force-pushed the fix/macos-sim-startup branch from fcab9e0 to 320e279 Compare March 2, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS sim startup crashes with CoreFoundation fork error after raylib load

1 participant