Skip to content

Panic when used on .wasm built with -C link-arg=--shared #1420

Closed
@hpohl

Description

@hpohl

When trying to use wasm-bindgen on a .wasm file built with -C link-arg=--shared, it panics when using closures.

Steps to Reproduce

$ rustup default beta (or nightly)
$ cargo init --lib
$ cat src/lib.rs
use wasm_bindgen::prelude::*;

#[no_mangle]
pub extern "C" fn foo() {
    Closure::wrap(Box::new(move || { }) as Box<dyn FnMut()>);
}
$ cat .cargo/config
[target.wasm32-unknown-unknown]
rustflags = [
    "-C", "link-arg=--shared",
]
$ cargo build --target=wasm32-unknown-unknown
$ wasm-bindgen target/wasm32-unknown-unknown/debug/file.wasm --out-dir out
thread 'main' panicked at 'out of bounds read of function table', src/libcore/option.rs:1038:5

Additional Context

Using the latest wasm-bindgen from github also panics, but at a different location.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions