Skip to content

skip PythonProcess preimport on macOS#37506

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

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

Conversation

@utkarshgill
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown
Contributor

This PR has had no activity for 24 days. It will be automatically closed in 7 days if there is no activity.

@github-actions github-actions Bot added the stale label Mar 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 4, 2026

This PR has been automatically closed due to inactivity. Feel free to re-open once activity resumes.

@github-actions github-actions Bot closed this Apr 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 4, 2026

This PR has been automatically closed due to inactivity. Feel free to re-open once activity resumes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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