Skip to content

SIGSEGV when compiling regex_automata wasm32-unknown-emscripten #69364

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

Closed
lopopolo opened this issue Feb 22, 2020 · 6 comments
Closed

SIGSEGV when compiling regex_automata wasm32-unknown-emscripten #69364

lopopolo opened this issue Feb 22, 2020 · 6 comments
Assignees
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lopopolo
Copy link
Contributor

lopopolo commented Feb 22, 2020

Code

$ rustc --crate-name regex_automata /Users/lopopolo/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-automata-0.1.8/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=53e0301393a8dd99 -C extra-filename=-53e0301393a8dd99 --out-dir /Users/lopopolo/dev/artichoke/playground/target/wasm32-unknown-emscripten/debug/deps --target wasm32-unknown-emscripten -L dependency=/Users/lopopolo/dev/artichoke/playground/target/wasm32-unknown-emscripten/debug/deps -L dependency=/Users/lopopolo/dev/artichoke/playground/target/debug/deps --extern byteorder=/Users/lopopolo/dev/artichoke/playground/target/wasm32-unknown-emscripten/debug/deps/libbyteorder-72d386ad6d326ca8.rmeta --cap-lints allow
{"artifact":"/Users/lopopolo/dev/artichoke/playground/target/wasm32-unknown-emscripten/debug/deps/regex_automata-53e0301393a8dd99.d","emit":"dep-info"}
{"artifact":"/Users/lopopolo/dev/artichoke/playground/target/wasm32-unknown-emscripten/debug/deps/libregex_automata-53e0301393a8dd99.rmeta","emit":"metadata"}
Called function must be a pointer!
  call addrspace(16046453) void <badref>(i8* %20), !dbg !53
in function _ZN4core6option15Option$LT$T$GT$5ok_or17h536d2927739d3b4fE
LLVM ERROR: Broken function found, compilation aborted!

Meta

rustc --version --verbose:

rustc 1.41.0 (5e1a79984 2020-01-27)
binary: rustc
commit-hash: 5e1a799842ba6ed4a57e91f7ab9435947482f7d8
commit-date: 2020-01-27
host: x86_64-apple-darwin
release: 1.41.0
LLVM version: 9.0

emcc --version:

emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.39.8 (commit 1458145cf4f3db0fb548343e6acab267eef8e4ef)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Release builds complete successfully.

Error output

Called function must be a pointer!
  call addrspace(16046453) void <badref>(i8* %20), !dbg !53
in function _ZN4core6option15Option$LT$T$GT$5ok_or17h536d2927739d3b4fE
LLVM ERROR: Broken function found, compilation aborted!
Backtrace

{"artifact":"/Users/lopopolo/dev/artichoke/playground/target/wasm32-unknown-emscripten/debug/deps/regex_automata-53e0301393a8dd99.d","emit":"dep-info"}
{"artifact":"/Users/lopopolo/dev/artichoke/playground/target/wasm32-unknown-emscripten/debug/deps/libregex_automata-53e0301393a8dd99.rmeta","emit":"metadata"}
Called function must be a pointer!
  call addrspace(6475917) void Segmentation fault: 11

@lopopolo lopopolo 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 Feb 22, 2020
@lopopolo
Copy link
Contributor Author

I created this as an internal compiler error. I'm not sure if that's right since this is a segfault and not a panic.

lopopolo added a commit to artichoke/playground that referenced this issue Feb 22, 2020
Rust 1.41.0 uses the upstream LLVM backend to build emscripten targets.
This enables upgrading the `emscripten-toolchain` for building mruby to
the latest upstream compiler.

This replaces the fastcomp compiler dependency which had some optimizer
bugs that caused crashes when compiling debug builds. (Debug builds
still do not work - `regex_automata` segfaults rustc - see
rust-lang/rust#69364.
@jonas-schievink jonas-schievink added A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ I-nominated and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Feb 22, 2020
@pnkfelix pnkfelix added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Feb 27, 2020
@pnkfelix
Copy link
Member

triage: P-high to determine underlying issue and actual severity, and the regression point. Removing nomination. Assigning to self.

@pnkfelix pnkfelix added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Feb 27, 2020
@pnkfelix pnkfelix self-assigned this Feb 27, 2020
@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Feb 27, 2020
@lopopolo
Copy link
Contributor Author

lopopolo commented Feb 28, 2020

Put together a smaller reproducer:

Cargo.toml

[package]
name = "bisect"
version = "0.1.0"
authors = ["Ryan Lopopolo <rjl@hyperbo.la>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ansi_term = "0.11"

src/main.rs:

fn main() {
    println!("Hello, world!");
}

This project segfaults rustc when running:

  • cargo +1.41.1 build --target wasm32-unknown-emscripten
  • cargo +1.41.0 build --target wasm32-unknown-emscripten
  • cargo +1.40.0 build --target wasm32-unknown-emscripten

With this emcc (1.39.8-upstream):

$ emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.39.8 (commit 1458145cf4f3db0fb548343e6acab267eef8e4ef)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Rust 1.39 and older use the fastcomp backend which is incompatible with the default "upstream" (LLVM) backend. Downgrading emcc to 1.38.48-fastcomp enables builds to succeed on 1.37.0, 1.38.0, and 1.39.0.

The segfault does not appear on this nightly.

rustc +nightly --version --verbose
rustc 1.43.0-nightly (6d69caba1 2020-02-27)
binary: rustc
commit-hash: 6d69caba110c0c2fb90180df1cbc8be5033b91d4
commit-date: 2020-02-27
host: x86_64-apple-darwin
release: 1.43.0-nightly
LLVM version: 9.0

@pnkfelix
Copy link
Member

pnkfelix commented Mar 10, 2020

Determined via bisection over nightlies that the problem was "fixed" between +nightly-2020-01-25 and +nightly-2020-01-26

Update: More info on those nightlies:

13-28-06 issue69364/repro (git:) % rustc +nightly-2020-01-25 --version
rustc 1.42.0-nightly (c2d141df5 2020-01-24)
13-28-14 issue69364/repro (git:) % rustc +nightly-2020-01-26 --version
rustc 1.42.0-nightly (6d3f4e0aa 2020-01-25)
13-28-16 issue69364/repro (git:) % ( cd ../../rust.git/ && git log c2d141df5..6d3f4e0aa --author=bors --format=oneline )
6d3f4e0aab3e36ceb8b83d1e9467514685f6b751 Auto merge of #68530 - estebank:abolish-ice, r=petrochenkov
8ad83afe5bcfa983a24b6f720c9ef389350f414b Auto merge of #68525 - tlively:emcc-codegen-sigsegv-66308, r=alexcrichton
3bf71b3d5c07afc0908881a0868080ed399ca6ca Auto merge of #68516 - oli-obk:spaces, r=eddyb
80a65bcaf2f2b8a5c659b21b32b42bc300338a0e Auto merge of #68448 - maurer:dyn-cdylib, r=alexcrichton
8bf17584e01d85c631bcb19b7cd0f95e84c9a9b1 Auto merge of #68269 - csmoe:temp, r=estebank
8647aa1a2ce279f8ec7cc5252d10b8cb9ea504eb Auto merge of #68526 - JohnTitor:rollup-3mmljof, r=JohnTitor
13-28-19 issue69364/repro (git:) % 

@pnkfelix
Copy link
Member

Looks like this was deliberately fixed via an LLVM upgrade in PR #68525.

@pnkfelix
Copy link
Member

And it looks like the above fix is part of the beta channel, which is imminently scheduled for release.

Closing as duplicate of #66308 (which is fixed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ P-high High priority 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

3 participants