Rustc segfaults with -C passes=livestacks

dcf88f2
Opened by Ruud van Asseldonk at 2019-11-22 20:42:35

How to reproduce:

mkdir /tmp/repro
cd /tmp/repro
cargo init --bin
mkdir .cargo
echo '[build]\nrustflags = ["-C", "passes=livestacks"]' > .cargo/config
cargo build --verbose

Output:

   Compiling repro v0.1.0 (file:///tmp/repro)
     Running `rustc --crate-name repro src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=10c9440624901274 -C extra-filename=-10c9440624901274 --out-dir /tmp/repro/target/debug/deps -L dependency=/tmp/repro/target/debug/deps -C passes=livestacks`
error: Could not compile `repro`.

Caused by:
  process didn't exit successfully: `rustc --crate-name repro src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=10c9440624901274 -C extra-filename=-10c9440624901274 --out-dir /tmp/repro/target/debug/deps -L dependency=/tmp/repro/target/debug/deps -C passes=livestacks` (signal: 11, SIGSEGV: invalid memory reference)

The livestacks pass is listed by rustc -C passes=list.

Reproduces on 1.21 and nightly:

rustc --version
rustc 1.21.0 (3b72af97e 2017-10-09)
rustc +nightly --version
rustc 1.24.0-nightly (1956d5535 2017-12-03)
  1. passes=stack-coloring results in the same issue.

    Ruud van Asseldonk at 2017-12-04 15:56:49

  2. Almost surely a LLVM crash.

    Simonas Kazlauskas at 2017-12-04 16:53:38

  3. The problem here is that livestacks is a machine function pass, but we're adding it to the main optimization pass manager. We already have code that distinguishes pass kinds and rejects those we do not (currently) support, but it is based on PassKind, which does not distinguish between function passes and machine function passes.

    Nikita Popov at 2018-11-03 20:36:55