Open
Description
opened on Oct 31, 2024
This is target wasm32-wasip1
with panic = "unwind"
, running on V8. I tried this code:
struct Dropper;
impl Drop for Dropper {
fn drop(&mut self) {
let _ = std::panic::catch_unwind(|| {
std::panic::resume_unwind(Box::new(String::from("About to do some nifty corruption")))
});
}
}
fn main() {
let _dropper = Dropper;
panic!("Triggering landing pad");
}
I expected to see this happen: a panic message, followed by the process exit.
Instead, this happened:
thread 'main' panicked at src/main.rs:13:5:
Triggering landing pad
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
wasm://wasm/garbage2-65ce2afe6e737f0d.wasm-0003f686:1
RuntimeError: memory access out of bounds
at garbage2-65ce2afe6e737f0d.wasm.dlfree (wasm://wasm/garbage2-65ce2afe6e737f0d.wasm-0003f686:wasm-function[140]:0x7464)
at garbage2-65ce2afe6e737f0d.wasm.free (wasm://wasm/garbage2-65ce2afe6e737f0d.wasm-0003f686:wasm-function[139]:0x70bc)
at garbage2-65ce2afe6e737f0d.wasm.__rdl_dealloc (wasm://wasm/garbage2-65ce2afe6e737f0d.wasm-0003f686:wasm-function[26]:0xe0e)
at garbage2-65ce2afe6e737f0d.wasm.__rust_dealloc (wasm://wasm/garbage2-65ce2afe6e737f0d.wasm-0003f686:wasm-function[14]:0x577)
at garbage2-65ce2afe6e737f0d.wasm._ZN3std2rt19lang_start_internal17hfafca2af8f4e8869E (wasm://wasm/garbage2-65ce2afe6e737f0d.wasm-0003f686:wasm-function[72]:0x2b91)
at garbage2-65ce2afe6e737f0d.wasm.__main_void (wasm://wasm/garbage2-65ce2afe6e737f0d.wasm-0003f686:wasm-function[12]:0x545)
at garbage2-65ce2afe6e737f0d.wasm._start (wasm://wasm/garbage2-65ce2afe6e737f0d.wasm-0003f686:wasm-function[5]:0x297)
at WASI.start (node:wasi:136:7)
at file:///home/purplesyringa/garbage2/wasi.mjs:12:6
Node.js v20.4.0
Meta
rustc --version --verbose
:
rustc 1.84.0-nightly (1e4f10ba6 2024-10-29)
binary: rustc
commit-hash: 1e4f10ba6476e48a42a79b9f846a2d9366525b9e
commit-date: 2024-10-29
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1
node --version
:
v20.4.0
Compile with --release
, run with
import { WASI } from "node:wasi";
import { readFile } from "node:fs/promises";
const wasi = new WASI({
version: "preview1",
args: process.argv.slice(2),
env: process.env,
});
const wasm = await WebAssembly.compile(await readFile(process.argv[2]));
const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject());
wasi.start(instance);
I'm not sure if this is a rustc bug, an LLVM bug, or a V8 bug, but I thought this might be important to track.
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Panicking machineryCategory: This is a bug.Issue: Correct Rust code lowers to incorrect machine codeOperating system: Wasi, Webassembly System InterfaceTarget: WASM (WebAssembly), http://webassembly.org/Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Activity