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

x86_64-unknown-linux-musl binaries SIGSEGV during early initialization #74757

Closed
nagisa opened this issue Jul 25, 2020 · 7 comments
Closed

x86_64-unknown-linux-musl binaries SIGSEGV during early initialization #74757

nagisa opened this issue Jul 25, 2020 · 7 comments
Labels
O-musl Target: The musl libc O-NixOS Operating system: NixOS, https://nixos.org/ regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nagisa
Copy link
Member

nagisa commented Jul 25, 2020

Minimized reproducer

fn main() {}

// $ rustc --target=x86_64-unknown-linux-musl test.rs
// $ ./test
// fish: “./test” terminated by signal SIGSEGV (Address boundary error)

Stack trace:

(gdb) bt
#0  0x0000555555558193 in _start_c ()
#1  0x00007fffffffc6b9 in ?? ()
#2  0x00000000178bfbff in ?? ()
#3  0x0000000000000064 in ?? ()
#4  0x0000000000000000 in ?? ()

The faulting instruction is this:

0x0000555555558193 <+291>:   mov    0x8(%rdx),%rsi

The register value is not obviously wrong (i.e. its not 0 or something like that), so could be a buffer overrun of some sort.

rustc 1.45.0 (5c1f21c 2020-07-13) works.
rustc 1.46.0-beta.2 (6f95990 2020-07-23) fails.
rustc 1.47.0-nightly (5ef299e 2020-07-24) fails.

@nagisa nagisa added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. O-musl Target: The musl libc labels Jul 25, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 25, 2020
@cuviper
Copy link
Member

cuviper commented Jul 26, 2020

It works for me on all of those same versions.

Maybe it's a system toolchain issue? I'm using Fedora 32, and I don't have any system musl packages installed, so it will be purely using rust's version of the musl CRT objects.

@cuviper
Copy link
Member

cuviper commented Jul 26, 2020

Maybe #70740 or #73089? Both have reached beta but not yet stable.

@nagisa nagisa added the O-NixOS Operating system: NixOS, https://nixos.org/ label Jul 26, 2020
@nagisa
Copy link
Member Author

nagisa commented Jul 26, 2020

Marking as O-NixOS then where this was reproduced.

@nagisa
Copy link
Member Author

nagisa commented Jul 26, 2020

Disabling pie helps:

$ rustc --version; and rustc --target=x86_64-unknown-linux-musl test.rs -C relocation-model=static; and ./test
rustc 1.46.0-beta.2 (6f959902b 2020-07-23)
$ echo $status
0

@nagisa
Copy link
Member Author

nagisa commented Jul 26, 2020

It looks like the issue is coming from the fact that on NixOS cc wraps gcc to add the following arguments

  -Wl\,-dynamic-linker
  -Wl\,/nix/store/jx19wa4xlh9n4324xdl9rjnykd19mmq3-glibc-2.30/lib/ld-linux-x86-64.so.2

If the wrapper is not utilized, or these arguments are removed, the binary runs correctly. Conversely if its run with the interpreter directly it also faults even if the DT_INTERP is not set:

/nix/store/jx19wa4xlh9n4324xdl9rjnykd19mmq3-glibc-2.30/lib/ld-linux-x86-64.so.2 ./test
fish: “/nix/store/jx19wa4xlh9n4324xdl9…” terminated by signal SIGSEGV (Address boundary error)

Possibly not a rustc bug either way.

@LeSeulArtichaut
Copy link
Contributor

Possibly not a rustc bug either way.

@nagisa what do you think would be the next steps to resolve this?

@nagisa
Copy link
Member Author

nagisa commented Jul 26, 2020

It likely deserves an issue report to both nixos and musl upstreams. I’m going to do it as time permits. Then this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-musl Target: The musl libc O-NixOS Operating system: NixOS, https://nixos.org/ regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants