-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed as not planned
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-LTOArea: Link-time optimization (LTO)Area: Link-time optimization (LTO)C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/
Description
It seems that the following code:
#![feature(wasm_abi)]
#[no_mangle]
pub extern "wasm" fn test() {
format!("boom: {}", 0u128);
}can result in invalid WASM being generated in case it is compiled with lto = true. I've created a repository with the minimal example that reproduces the issue when built with (tested on rustc 1.56.0-nightly (0035d9dce 2021-08-16)):
cargo build --target wasm32-unknown-unknown --release
Parsing the generated WASM will produce an error similar to the following:
[parse exception: attempted pop from empty stack / beyond block start boundary at 536 (at 0:536)]
Fatal: error parsing wasm
Using an argument of type u64 or disabling lto or using the C ABI instead of wasm ABI (which enables LLVM's multivalue feature) works.
Meta
rustc --version --verbose:
rustc 1.56.0-nightly (0035d9dce 2021-08-16)
binary: rustc
commit-hash: 0035d9dcecee49d1f7349932bfa52c05a6f83641
commit-date: 2021-08-16
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1
mitar, ptrus and temeddix
Metadata
Metadata
Assignees
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-LTOArea: Link-time optimization (LTO)Area: Link-time optimization (LTO)C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/