Skip to content

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

Not planned
@jmjoy

Description

@jmjoy

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

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Aug 28, 2020
jmjoy

jmjoy commented on Aug 28, 2020

@jmjoy
Author

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

tesuji commented on Aug 28, 2020

@tesuji
Contributor

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

tesuji commented on Aug 28, 2020

@tesuji
Contributor

Related issue: #74757

added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Aug 28, 2020
12101111

12101111 commented on Aug 28, 2020

@12101111
Contributor

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

tesuji commented on Aug 28, 2020

@tesuji
Contributor

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 commented on Aug 28, 2020

@LeSeulArtichaut
Contributor

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

spastorino

spastorino commented on Sep 2, 2020

@spastorino
Member

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

added and removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Sep 2, 2020

6 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️O-muslTarget: The musl libcP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @spastorino@Enselic@12101111@jmjoy@Dylan-DPC-zz

        Issue actions

          1.46.0: Throw "SIGSEGV: invalid memory reference" when building in alpine. · Issue #76021 · rust-lang/rust