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

1.46.0: Throw "SIGSEGV: invalid memory reference" when building in alpine. #76021

Closed
jmjoy opened this issue Aug 28, 2020 · 8 comments
Closed
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-musl Target: The musl libc P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jmjoy
Copy link

jmjoy commented Aug 28, 2020

Code

# Dockerfile

FROM alpine:3.8

USER root

ENV USER=root

RUN apk add --no-cache openssl openssl-dev curl gcc

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

WORKDIR /tmp

RUN sh -c "source /root/.cargo/env && cargo new --bin app"

WORKDIR /tmp/app

RUN echo 1.46.0 > rust-toolchain

RUN echo 'rand = "*"' >> Cargo.toml

RUN sh -c "source /root/.cargo/env && cargo build"

Meta

docker build .

Error output

The last step:

Step 11/11 : RUN sh -c "source /root/.cargo/env && cargo build"
 ---> Running in c554b90561db
info: syncing channel updates for '1.46.0-x86_64-unknown-linux-musl'
info: latest update on 2020-08-27, rust version 1.46.0 (04488afe3 2020-08-24)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
    Updating crates.io index
 Downloading crates ...
  Downloaded rand_chacha v0.2.2
  Downloaded rand_core v0.5.1
  Downloaded getrandom v0.1.14
  Downloaded libc v0.2.76
  Downloaded ppv-lite86 v0.2.9
  Downloaded rand v0.7.3
  Downloaded cfg-if v0.1.10
   Compiling libc v0.2.76
   Compiling getrandom v0.1.14
   Compiling cfg-if v0.1.10
   Compiling ppv-lite86 v0.2.9
error: failed to run custom build command for `getrandom v0.1.14`

Caused by:
  process didn't exit successfully: `/tmp/app/target/debug/build/getrandom-64ae542341c0eb62/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: build failed
The command '/bin/sh -c sh -c "source /root/.cargo/env && cargo build"' returned a non-zero code: 101

@jmjoy jmjoy added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 28, 2020
@jmjoy
Copy link
Author

jmjoy commented Aug 28, 2020

Not only crate rand, but replacing rand with log will also have this error:

    Updating crates.io index
 Downloading crates ...
  Downloaded log v0.4.11
  Downloaded cfg-if v0.1.10
   Compiling log v0.4.11
   Compiling cfg-if v0.1.10
error: failed to run custom build command for `log v0.4.11`

Caused by:
  process didn't exit successfully: `/tmp/app/target/debug/build/log-ec0bf32b8f3a6724/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)

@tesuji
Copy link
Contributor

tesuji commented Aug 28, 2020

Actually I just need libc = "0.2" to reproduce the issue.

Bisection result

searched nightlies: from nightly-2020-06-19 to nightly-2020-06-21
regressed nightly: nightly-2020-06-20
searched commits: from e55d3f9 to 2d8bd9b
regressed commit: 63b441a

bisected with cargo-bisect-rustc v0.5.2

Host triple: x86_64-unknown-linux-musl
Reproduce with:

cargo bisect-rustc 2020-06-19 --end 2020-06-21 --without-cargo 

Most likely #70740, cc @petrochenkov as reviewer of that PR.

@tesuji
Copy link
Contributor

tesuji commented Aug 28, 2020

Related issue: #74757

@Dylan-DPC-zz Dylan-DPC-zz added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Aug 28, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 28, 2020
@12101111
Copy link
Contributor

12101111 commented Aug 28, 2020

I can't repoduce this on my musl based Gentoo linux system, which use musl 1.2.1.

> cd /tmp
> cargo new app
     Created binary (application) `app` package
> cd app
> echo 1.46.0 > rust-toolchain
> echo 'rand = "*"' >> Cargo.toml
> cargo build
info: syncing channel updates for '1.46.0-x86_64-unknown-linux-musl'
info: latest update on 2020-08-27, rust version 1.46.0 (04488afe3 2020-08-24)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
    Updating crates.io index
   Compiling libc v0.2.76
   Compiling getrandom v0.1.14
   Compiling cfg-if v0.1.10
   Compiling ppv-lite86 v0.2.9
   Compiling rand_core v0.5.1
   Compiling rand_chacha v0.2.2
   Compiling rand v0.7.3
   Compiling app v0.1.0 (/tmp/app)
    Finished dev [unoptimized + debuginfo] target(s) in 10.82s
> ldd target/debug/app
	ldd (0x7f321a2c1000)
> file target/debug/app
target/debug/app: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
> ./target/debug/app
Hello, world!

Alpine 3.8 use musl 1.1.19 but rust CI use musl 1.1.24, and I'm sure musl don't have any binary forward compatibility (Yestday I try to downgrade musl to 1.1.24 and all programs I compile recently ware broken and show same error (signal: 11, SIGSEGV: invalid memory reference))

Other test in docker:
Alpine 3.8:

info: syncing channel updates for '1.46.0-x86_64-unknown-linux-musl'
info: latest update on 2020-08-27, rust version 1.46.0 (04488afe3 2020-08-24)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
    Updating crates.io index
 Downloading crates ...
  Downloaded rand_chacha v0.2.2
  Downloaded rand_core v0.5.1
  Downloaded cfg-if v0.1.10
  Downloaded getrandom v0.1.14
  Downloaded ppv-lite86 v0.2.9
  Downloaded libc v0.2.76
  Downloaded rand v0.7.3
   Compiling libc v0.2.76
   Compiling getrandom v0.1.14
   Compiling cfg-if v0.1.10
   Compiling ppv-lite86 v0.2.9
error: failed to run custom build command for `getrandom v0.1.14`

Caused by:
  process didn't exit successfully: `/tmp/app/target/debug/build/getrandom-64ae542341c0eb62/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...

Alpine 3.9

info: syncing channel updates for '1.46.0-x86_64-unknown-linux-musl'
info: latest update on 2020-08-27, rust version 1.46.0 (04488afe3 2020-08-24)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
    Updating crates.io index
 Downloading crates ...
  Downloaded libc v0.2.76
  Downloaded ppv-lite86 v0.2.9
  Downloaded rand_core v0.5.1
  Downloaded cfg-if v0.1.10
  Downloaded rand_chacha v0.2.2
  Downloaded rand v0.7.3
  Downloaded getrandom v0.1.14
   Compiling libc v0.2.76
   Compiling getrandom v0.1.14
   Compiling cfg-if v0.1.10
   Compiling ppv-lite86 v0.2.9
   Compiling rand_core v0.5.1
   Compiling rand_chacha v0.2.2
   Compiling rand v0.7.3
   Compiling app v0.1.0 (/tmp/app)
    Finished dev [unoptimized + debuginfo] target(s) in 33.04s

3.10

info: syncing channel updates for '1.46.0-x86_64-unknown-linux-musl'
info: latest update on 2020-08-27, rust version 1.46.0 (04488afe3 2020-08-24)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
    Updating crates.io index
 Downloading crates ...
  Downloaded rand_chacha v0.2.2
  Downloaded rand_core v0.5.1
  Downloaded cfg-if v0.1.10
  Downloaded getrandom v0.1.14
  Downloaded libc v0.2.76
  Downloaded ppv-lite86 v0.2.9
  Downloaded rand v0.7.3
   Compiling libc v0.2.76
   Compiling getrandom v0.1.14
   Compiling cfg-if v0.1.10
   Compiling ppv-lite86 v0.2.9
   Compiling rand_core v0.5.1
   Compiling rand_chacha v0.2.2
   Compiling rand v0.7.3
   Compiling app v0.1.0 (/tmp/app)
    Finished dev [unoptimized + debuginfo] target(s) in 1m 03s

@tesuji
Copy link
Contributor

tesuji commented Aug 28, 2020

Cool. @jmjoy so the answer is to upgrade alpine to newer version (easy) or just upgrade musl (hard).
This could be closed as won't fix.

@LeSeulArtichaut LeSeulArtichaut added the O-musl Target: The musl libc label Aug 28, 2020
@LeSeulArtichaut
Copy link
Contributor

Tagged this issue as O-musl, please correct me if that's wrong

@spastorino
Copy link
Member

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@Enselic
Copy link
Member

Enselic commented Aug 29, 2023

Triage: Closing, because

  • it was suggested this can be closed, and there were no objections.
  • the related issue suggests this is a problem with the host toolchain rather than what rustc ships
  • the musl version shipped with Rust was recently bumped, so this old issue seem less relevant to keep open.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-musl Target: The musl libc P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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

8 participants