From 1a20847a31e78ecaea48e2347676bd83dbd9d52c Mon Sep 17 00:00:00 2001 From: mkultraWasHere Date: Fri, 15 May 2026 17:10:18 -0400 Subject: [PATCH] fix: disable ObjC fork safety check on macOS for Ansible workers On macOS with Python 3.14, the ObjC runtime aborts forked child processes when class initialisation (+[NSNumber initialize]) is in progress at fork time. This causes Ansible worker processes to crash with "A worker was found in a dead state" on every playbook run. Setting OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES in the Ansible subprocess environment prevents the crash. --- cli/internal/ansible/runner.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cli/internal/ansible/runner.go b/cli/internal/ansible/runner.go index 64c76496..c655d498 100644 --- a/cli/internal/ansible/runner.go +++ b/cli/internal/ansible/runner.go @@ -11,6 +11,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "sync/atomic" "syscall" @@ -229,6 +230,16 @@ func buildArgs(opts RunOptions, cfg *config.Config) []string { func buildEnv(opts RunOptions, cfg *config.Config) ([]string, error) { env := os.Environ() + // On macOS, the ObjC runtime aborts forked child processes when class + // initialisation is in progress at fork time. Ansible forks workers + // heavily, which triggers: + // "+[NSNumber initialize] may have been in progress in another thread + // when fork() was called … Crashing instead." + // Setting this variable tells the runtime to skip the check. + if runtime.GOOS == "darwin" { + env = append(env, "OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES") + } + ansibleEnv, err := cfg.AnsibleEnv() if err != nil { return nil, fmt.Errorf("ansible env: %w", err)