nix-community / nix-eval-jobs

Parallel nix evaluator with a streamable json output [maintainers @Mic92, @adisbladis]
GNU General Public License v3.0
157 stars 31 forks source link

objc fork crash in recent version on aarch64-darwin #301

Closed leona-ya closed 5 months ago

leona-ya commented 6 months ago

With the update of nix-eval jobs from an older nixpkgs rev (https://github.com/nixos/nixpkgs/commit/1042fd8b148a9105f3c0aca3a6177fd1d9360ba5) to current master with nix-eval-jobs 2.21.0, nix-eval-jobs crashes with

❯ nix run 'github:nixOS/nixpkgs?rev=f112bff35de093908939d67b1b50231fb40b30b5#nix-eval-jobs' -- \
     --gc-roots-dir $(mktemp -d) \
     --workers 1 \
     --flake 'github:entropia/nix-files#checks.aarch64-darwin'
warning: unknown setting 'allowed-users'
warning: unknown setting 'trusted-users'
objc[44558]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[44558]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
error: error: while checking worker process, evaluation worker got killed by signal 6 (Abort trap: 6)

on aarch64-darwin. It doesn't happen on linux.

This failure is reproducible. I unfortunately don't know how to better trace this on macOS :/

leona-ya commented 6 months ago

Also interestingly: This happens also with a non-existing flake, so it seems to happen before checking that.

Mic92 commented 6 months ago

I think I have seen this yesterday in nix-fast-build: https://github.com/Mic92/nix-fast-build/actions/runs/8926049540/job/24516185484

 warning: 'show-config' is a deprecated alias for 'config show'
INFO:nix_fast_build:run nix-eval-jobs --gc-roots-dir /tmp/tmpt8g37u5g/gcroots --force-recurse --max-memory-size 2048 --workers 1 --flake '.#checks'
warning: unknown setting 'trusted-users'
error: error: while reading result for attrPath 'aarch64-darwin', evaluation worker got killed by SIGBUS, (possible infinite recursion)
ERROR:nix_fast_build:nix-eval-jobs exited with 1
25h

However I cannot reproduce this on the macos builder that I have access to. So I need help with this.

Mic92 commented 6 months ago

So there is some function in nix that we are not allowed to call from a multi-threaded context...

Mic92 commented 6 months ago

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES is usually mentioned as the fix, but it doesn't seem to work here.

Mic92 commented 6 months ago

I can no longer see the crash after https://github.com/nix-community/nix-eval-jobs/pull/302

Mic92 commented 6 months ago

No. Still an issue: https://github.com/Mic92/nix-fast-build/actions/runs/9015595396/job/24770558899?pr=63#step:4:349

Mic92 commented 6 months ago

For now I will pin this to an old release: https://github.com/NixOS/nixpkgs/pull/310301

Mic92 commented 5 months ago

After https://github.com/nix-community/nix-eval-jobs/commit/32071eb9635dbe0e1e8fc750ea1aac6808272018 I am no longer able to reproduce this error.

anmonteiro commented 5 months ago

I also can't reproduce this anymore. Thanks for fixing