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

SIGSEGV when compiling for target wasm32-unknown-unknown with LLVM target feature 'multivalue' #73916

Open
adrian17 opened this issue Jul 1, 2020 · 9 comments
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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/ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@adrian17
Copy link

adrian17 commented Jul 1, 2020

I tried this code:

pub fn f() -> ! {
    panic!("");
}

With compiler invocation: rustc --crate-type lib mytest.rs --target wasm32-unknown-unknown -C target-feature=+multivalue

I expected to see this happen: no failure

Instead, this happened:

Segmentation fault (core dumped)

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (16957bd4d 2020-06-30)
binary: rustc
commit-hash: 16957bd4d3a5377263f76ed74c572aad8e4b7e59
commit-date: 2020-06-30
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
Backtrace

No backtrace.

Can also be reproduced on godbolt with current nightly: https://godbolt.org/z/Pqg986
Also, there is no crash when the feature is not enabled (not mentioned at all or -C target-feature=-multivalue), or when I build with -O.

@adrian17 adrian17 added the C-bug Category: This is a bug. label Jul 1, 2020
@jonas-schievink jonas-schievink added 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/ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 1, 2020
@adrian17
Copy link
Author

adrian17 commented Jul 1, 2020

(Probably A-LLVM?)

@CryZe
Copy link
Contributor

CryZe commented Jul 3, 2020

It seems like using u128 / i128 segfaults multivalue as well on beta and nightly. It works on 1.44.
https://rust.godbolt.org/z/AXRnar

This seems like a regression in LLVM 10.

@adrian17
Copy link
Author

adrian17 commented Jul 3, 2020

This seems like a regression in LLVM 10.

I think the feature wasn't actually implemented prior to LLVM 10.

@CryZe
Copy link
Contributor

CryZe commented Jul 3, 2020

Ah yeah seems like it

@alexcrichton
Copy link
Member

I tested this on LLVM trunk and wasn't able to reproduce the same crash, so this will likely get fixed when we update LLVM.

@adrian17
Copy link
Author

adrian17 commented Aug 25, 2020

With recent LLVM upgrade this particular crash disappears, but in general it still segfaults when compiling a nontrivial crate, like svg.

New example:

// --target wasm32-unknown-unknown -C target-feature=+multivalue -O

pub fn read_number(number: &str) -> Result<f32, std::num::ParseFloatError> {
    number.parse()
}

Godbolt: https://godbolt.org/z/TTffx3

@adrian17
Copy link
Author

For the record, the example above is still reproducible after LLVM 12 upgrade.

@adrian17
Copy link
Author

adrian17 commented Jun 16, 2021

I made a more low-level reproduction of the example above:

https://github.com/adrian17/multivalue-crash-repro/

(unfortunately I couldn't put it on godbolt, as without the crate boundary it compiled correctly)

I'm guessing it's originating from compiling this line:

f32::from_bits(bits.try_into().unwrap_or_else(|_| unreachable!()))

And remaining code is there just to defeat optimizations that would un-break later passes.

@daxpedda
Copy link
Contributor

daxpedda commented Jun 6, 2023

I just confirmed that this has been working since v1.62.

@workingjubilee workingjubilee added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 12, 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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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/ 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

6 participants