test: add shebangs to shell.nix test scripts#14778
Conversation
Fix intermittent SIGSEGV (exit code 139) on macOS when running nix-shell and shebang tests inside the nix sandbox. The foo, bar, and ruby test scripts were created without shebangs, which causes intermittent crashes when executed via command substitution on macOS. Adding proper shebangs resolves the flakiness. Potentially closes: NixOS#13106
47f6743 to
7b3d7eb
Compare
xokdvium
left a comment
There was a problem hiding this comment.
Can't even fathom how this leads to segfaults and at this point I'm too afraid to ask.
I did some digging, and as far as I can tell, it's because under macOS fork-without-exec is an unsafe operation. When I believe it's the same issue as the one reported at benoitc/gunicorn#2761 Having said all this, I couldn't find a minimally reproducible example that doesn't rely on an environment created by |
Probably the specific macOS sandbox profile has to do with it? |
Nope, apparently it happens without the sandbox profile enabled, too. I'm now trying to figure out if it's stdenv related, in which case there might be a more serious bug elsewhere. |
|
@xokdvium want to hear something even more crazy? The bug just generally affects the use of I'm cooking the most cursed reproduction scripts right now... My plain version looks like: My patched version with ncurses is: I'll continue my journey into the depths of hell tomorrow, trying to figure out what's ncurses doing and if this is bash's fault. |
|
Successfully created backport PR for |
|
Successfully created backport PR for |
|
Successfully created backport PR for |
|
Successfully created backport PR for |
|
Successfully created backport PR for |
|
Successfully created backport PR for |
|
Successfully created backport PR for |
macos-builder02 in particular has been having problems for a while now that no one could reproduce. We believe we have finally found the cause: missing shebangs, not just in the tests themselves but *also* in the inline scripts `nix-shell` itself writes. Fixes #1042. I believe this will also fix #1093. See also: NixOS/nix#14778 Change-Id: I54d04a770b8e78484815db88a8bc88776a6a6964
this will fix nix devshell failing on darwin machine The fix was introduced on: <NixOS/nix#14778> Signed-off-by: Seongmin Lee <git@boltless.me>
Summary
Adds shebangs to the
foo,bar, andrubytest scripts intests/functional/shell.nixto fix intermittent SIGSEGV crashes on macOS.Motivation
Some of the test scripts used for the functional test are created without shebangs, which causes a ~50% build failure rate on macOS (particularly Apple Silicon) caused by SIGSEGVs when the scripts are executed via command substitution inside the nix sandbox.
See #12121 for my root cause analysis and a minimal reproduction script.
Solution
Add
#!${shell}shebangs to each test script. With this fix, builds pass consistently (10/10 vs 5/10 without the patch).Testing
Likely fixes some of the problems people had in #13106, though not all test failures reported are caused by this.