Skip to content

bootstrap-tools binaries crash on aarch64 with 64k page size #112086

@graham33

Description

@graham33

Describe the bug
bootstrap-tools binaries such as bash, patchelf etc. crash with SIGSEGV on aarch64 with 64k page size configured.

Non-bootstrap binaries (e.g. bash) from cache.nixos.org or built locally on the machine work fine. musl versions also appear unaffected.

To Reproduce
Steps to reproduce the behavior:

  1. Build and run a bootstrap bash:
nix-build '<nixpkgs>' -A stdenv.bootstrapTools                                                                                                   
/nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools

/nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/bin/bash
[1]    82249 segmentation fault  /nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/bin/bash
  1. Compare to regular bash which works fine:
nix-build '<nixpkgs>' -A bash                 
/nix/store/83zszzf9h5zrgaasga0wwm4jnpby4i1z-bash-4.4-p23

/nix/store/83zszzf9h5zrgaasga0wwm4jnpby4i1z-bash-4.4-p23/bin/bash -c 'echo hello'
hello
  1. ld-linux.so shows some extra information about the problem
file /nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/bin/bash
/nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/bin/bash: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/lib/ld-linux-aarch64.so.1, for GNU/Linux 2.6.32, stripped

/nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/lib/ld-linux-aarch64.so.1 /nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/bin/bash
/nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/bin/bash: error while loading shared libraries: /nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/bin/bash: ELF load command alignment not page-aligned
  1. Kernel page size is 64k:
getconf PAGESIZE
65536
  1. readelf shows difference in alignment for LOAD commands:
readelf -l /nix/store/fj18xk7dwk706mfki61klg69dg84gsim-bootstrap-tools/bin/bash | grep -A1 LOAD
  LOAD           0x0000000000000000 0x00000000003ff000 0x00000000003ff000
                 0x0000000000001000 0x0000000000001000  RW     0x1000
  LOAD           0x0000000000001000 0x0000000000400000 0x0000000000400000
                 0x00000000000c2c00 0x00000000000c2c00  R E    0x1000
--
  LOAD           0x00000000000c49a0 0x00000000004d39a0 0x000000000x10000004d39a0
                 0x0000000000005048 0x000000000000d4c8  RW     0x1000

readelf -l /nix/store/83zszzf9h5zrgaasga0wwm4jnpby4i1z-bash-4.4-p23/bin/bash | grep -A1 LOAD
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x00000000000c293c 0x00000000000c293c  R E    0x10000
  LOAD           0x00000000000c29a0 0x00000000004d29a0 0x00000000004d29a0
                 0x0000000000005048 0x000000000000d4c8  RW     0x10000

(0x1000 4k vs 0x10000 64K)

Expected behavior
Bash should run without error. I'm not too familiar with the details of ARM page sizes and alignment requirements, but it seems that alignment is required. See similar old issue here: https://stackoverflow.com/questions/20092390/arm-hello-world-not-starting-command-aligned-not-page-aligned

Additional context
Test system is an AWS Graviton 2 ARM host (t4g.medium) running RHEL 8:

uname -a
Linux xxxxx 4.18.0-240.8.1.el8_3.aarch64 #1 SMP Fri Dec 4 12:08:30 EST 2020 aarch64 aarch64 aarch64 GNU/Linux

cat /proc/cpuinfo 
processor  : 0
BogoMIPS        : 243.75
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x3
CPU part        : 0xd0c
CPU revision    : 1

processor       : 1
BogoMIPS        : 243.75
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x3
CPU part        : 0xd0c
CPU revision    : 1

musl appears to work:

/nix/store/n4fd6hhsg2ywvcbdpylb6d3fzk2l6sbn-bootstrap-tools/bin/bash -c "echo hello"
hello

file /nix/store/n4fd6hhsg2ywvcbdpylb6d3fzk2l6sbn-bootstrap-tools/bin/bash                
/nix/store/n4fd6hhsg2ywvcbdpylb6d3fzk2l6sbn-bootstrap-tools/bin/bash: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /nix/store/n4fd6hhsg2ywvcbdpylb6d3fzk2l6sbn-bootstrap-tools/lib/ld-musl-aarch64.so.1, stripped

Notify maintainers

@Ericson2314 noticed this originally

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"aarch64-linux"`
 - host os: `Linux 4.18.0-240.8.1.el8_3.aarch64, Red Hat Enterprise Linux, 8.3 (Ootpa)`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.10`
 - channels(ec2-user): `"nixpkgs-21.03pre268173.4cd977e60d6"`
 - nixpkgs: `/home/ec2-user/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions