Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aarch64-darwin segfault trying to build system #10138

Closed
n8henrie opened this issue Mar 4, 2024 · 5 comments
Closed

aarch64-darwin segfault trying to build system #10138

n8henrie opened this issue Mar 4, 2024 · 5 comments
Labels

Comments

@n8henrie
Copy link
Contributor

n8henrie commented Mar 4, 2024

Describe the bug

I get a segfault when trying to build my system config for unclear reasons.

Steps To Reproduce

$ nix --version
nix (Nix) 2.19.3
$ nix build .#darwinConfigurations.natepro.config.system.build.toplevel
warning: updating lock file '/Users/n8henrie/git/nixos/flake.lock':
• Updated input 'modules':
    'path:/nix/store/rfykzr3i5dkdyd0xmc85s97dgrbjbj6r-source/modules?lastModified=1&narHash=sha256-sw7mhb/Mmi%2B%2BuKyMQ6o4KmA8ntlB/sjbpCBYEhmn61U%3D' (1970-01-01)
  → 'path:/nix/store/sy04jkc24rjb0qrw5xpkp7k1915f8sgq-source/modules?lastModified=1&narHash=sha256-sw7mhb/Mmi%2B%2BuKyMQ6o4KmA8ntlB/sjbpCBYEhmn61U%3D' (1970-01-01)
• Updated input 'overlays':
    'path:/nix/store/rfykzr3i5dkdyd0xmc85s97dgrbjbj6r-source/overlays?lastModified=1&narHash=sha256-DeS%2BNSURhsiosvtWBrVDOEhvggzD4mZBpSbMkvN2B6c%3D' (1970-01-01)
  → 'path:/nix/store/sy04jkc24rjb0qrw5xpkp7k1915f8sgq-source/overlays?lastModified=1&narHash=sha256-DeS%2BNSURhsiosvtWBrVDOEhvggzD4mZBpSbMkvN2B6c%3D' (1970-01-01)
evaluating derivation 'git+file:///Users/n8henrie/git/nixos#darwinConfigurations.natepro.config.system.build.toplevel'Segmentation fault: 11

Expected behavior

System should build or an error should be emitted.

nix-env --version output

$ nix-env --version
nix-env (Nix) 2.19.3
$ nix-info -m
 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.3.0, macOS 14.3.1`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.19.3`
 - channels(n8henrie): `""`
 - channels(root): `""`
 - nixpkgs: `/nix/store/v30afjhzqrwra6mkizz12az6dbryg7pr-source`

Additional context

I'm refactoring my config to use nixpkgs-unstable instead of release-23.11.

Output of:

$ nix build .#darwinConfigurations.natepro.config.system.build.toplevel --debug -vvv

is at https://gist.github.com/n8henrie/643baa4a337c7d7c46ebf22cd2b03e82

Priorities

Add 👍 to issues you find important.

@n8henrie n8henrie added the bug label Mar 4, 2024
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/rust-in-nix-discussion-thread/5092/21

@n8henrie
Copy link
Contributor Author

n8henrie commented Mar 4, 2024

No luck with GC_DONT_GC=1 this time

@yorickvP
Copy link
Contributor

yorickvP commented Mar 4, 2024

IIRC: it's hard to detect stack overflows on darwin, the error message for that doesn't always work, so this might be an ordinary stack overflow instead of memory corruption.

@n8henrie
Copy link
Contributor Author

n8henrie commented Mar 4, 2024

Thanks for your input, I think you're probably correct.

This shows the basics idea of my flake setup, which has been working fairly well for the last year or so:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs";
    nixpkgs-stable.url = "github:nixos/nixpkgs/release-23.11";
  };

  outputs = {
    self,
    nixpkgs,
    ...
  } @ inputs: let
    inherit (nixpkgs) lib;

    hosts = {
      mymachine.system = "aarch64-darwin";
      othermachine = {
        system = "aarch64-darwin";
        nixpkgs = inputs.nixpkgs-stable;
      };
    };
  in
    lib.foldlAttrs (acc: hostname: conf: let
      nixpkgs = conf.nixpkgs or inputs.nixpkgs;
    in
      lib.recursiveUpdate acc {
        packages.${conf.system}.default = nixpkgs.legacyPackages.${conf.system}.hello;
      }) {}
    hosts;
}

(This minimal example builds, whereas mine segfaults.)

In my actually crashing flake, if I change nixpkgs = conf.nixpkgs or inputs.nixpkgs; to nixpkgs = conf.nixpkgs or self.inputs.nixpkgs;, I go from a segfault to an infinite recursion error, even though AFAICT inputs.nixpkgs and self.inputs.nixpkgs should be the same thing.

I'm also not sure why it gives me segfault or infinite recursion whereas this works. Maybe I'm barking up the wrong tree.

@n8henrie
Copy link
Contributor Author

n8henrie commented Mar 4, 2024

I noted that 2.20 seems to have some changes relevant to stack overflows; this seems to confirm the issue (with a much better error message):

$ nix run github:nixos/nix/2.20-maintenance -- build .#darwinConfigurations.natepro.config.system.build.toplevel
warning: updating lock file '/Users/n8henrie/git/nixos/flake.lock':
• Updated input 'modules':
    'path:/nix/store/4d3ygplv20ymmsx0az7yh136asmm1vr2-source/modules?lastModified=1&narHash=sha256-zPNgdnLrKUd2c0wMzH3wyivqivC5JQmAHMCEVz00ZG4%3D' (1970-01-01)
  → 'path:/nix/store/my2zyiknkk118jjblmf3gd3arcwf62hn-source/modules?lastModified=1&narHash=sha256-zPNgdnLrKUd2c0wMzH3wyivqivC5JQmAHMCEVz00ZG4%3D' (1970-01-01)
error:
       … while evaluating the attribute 'config'
         at /nix/store/8gsd9h76snq5sgcnwjip3c3p9wxbrjzm-source/lib/modules.nix:322:9:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/8gsd9h76snq5sgcnwjip3c3p9wxbrjzm-source/lib/modules.nix:322:18:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: stack overflow; max-call-depth exceeded
       at /nix/store/8gsd9h76snq5sgcnwjip3c3p9wxbrjzm-source/lib/trivial.nix:438:10:
          437|     then f.__functionArgs or (functionArgs (f.__functor f))
          438|     else builtins.functionArgs f;
             |          ^
          439|

I suspect this is already covered in #8281

Thanks for pointing me in the right direction @yorickvP!

@n8henrie n8henrie closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants