skip PythonProcess preimport on macOS#37506
Open
utkarshgill wants to merge 1 commit intocommaai:masterfrom
Open
skip PythonProcess preimport on macOS#37506utkarshgill wants to merge 1 commit intocommaai:masterfrom
utkarshgill wants to merge 1 commit intocommaai:masterfrom
Conversation
839c25f to
fcab9e0
Compare
…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.
fcab9e0 to
320e279
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #37504
manager.pymodule-level imports create OS threads (sentry) beforeunblock_stdout()callsos.forkpty(). The forkpty child -- which never exec's -- then runsprepare(), whichpreimports
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_SAFETYdoesn't work on macOS 14+. A full fix would bereworking
unblock_stdout()to avoid forkpty on macOS, but that's a bigger change.