Failed to build bootstrap-stage0-stdenv-linux.drv due to signal 11 (Segmentation fault)

Describe the bug

failed to build bootstrap-stage0-stdenv-linux.drv due to signal 11 (Segmentation fault)。
I confirm this will happen on arrch64 platform,but without problem on x86_64 platform.

Steps To Reproduce

  1. rebuild the nginx
  2. run nix-build '<nixpkgs>' --check -A nginx
  3. it will start to build package relative to bootstrap before rebuilding the nginx

Expected behavior

successfully building the bootstrap-stage0-stdenv-linux.drv file and the other boostrap derivation .

Screenshots

Additional context

relative issue Failed to build gcc9.4 due to signal 11 (Segmentation fault) · Issue #148391 · NixOS/nixpkgs · GitHub

Metadata

system : aarch64-linux
host os: centos 7.6
version: nix-2.4
sanbox: yes

Hi,

I assume your system is using 64k page. The issue is related to
patchelf, for some reason, in bootstrap-tools, it seems to have been
compiled with 4k page size.

I’ve have on overlay with:

patchelf = prev.patchelf.overrideAttrs ( attrs: {
configureFlags = (attrs.configureFlags or “”)
+ lib.optionalString (prev.patchelf.stdenv.hostPlatform.isAarch64) “–with-page-size=65536”;
});

and these 2 patches (in my nixpkgs fork):

https://github.com/dguibert/nixpkgs/commit/3e292c47d63b6dfa40c630fd9d840ccc3bf085ba
https://github.com/dguibert/nixpkgs/commit/abeec8475f58fe3a97e5e39cc060059442ba83d0

Hope this help

hrx via NixOS Discourse discourse@discourse.nixos.org writes:

1 Like

Indeed, the current system is using 64k page. So,this problem was also happend to you.Thanks for you solution, I’ll try it later.

And I really want to know how did you discover or think about this problem? The error reported from nix tool was not clear to identify the real location of error.

I would appreciate if you can share me someting about this,thank you again.

hrx via NixOS Discourse discourse@discourse.nixos.org writes:

And I really want to know how did you discover or think about this
problem? The error reported from nix tool was not clear to identify
the real location of error.

Was not ease to diagnose but I end up by running

$ /lib/ld-linux-aarch64.so.1 ./bash
./bash: error while loading shared libraries: ./bash: ELF load command alignment not page-aligned

bash comming from bootstrap-tools derivation… so the 2 patches :wink:

I reproduce this not page-aligned problem, and do you plan to make a PR to nixpkgs community?

@dguibert thanks - it looks like your patches might fix bootstrap-tools binaries crash on aarch64 with 64k page size · Issue #112086 · NixOS/nixpkgs · GitHub - if you could make a PR to nixpkgs I’d be keen to try it out! I guess the main thing to resolve from the patches you posted is just to factor out the page size to use - e.g. maybe just have a parameter to switch between 4k and 64k pages?

Hi, here is the PR fix bootstrap tools on aarch64 64k page size system by dguibert · Pull Request #150659 · NixOS/nixpkgs · GitHub