wasm-bindgen: Panic when used on .wasm built with -C link-arg=--shared
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.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- from what I can tell, relocatable wasm just doesn't work with wasm-bindgen sad https://github.com/rustwasm/wasm-bindgen/issues/1420 — committed to DioxusLabs/dioxus by jkelleyrtp 2 years ago
- Binary patching rust hot-reloading, sub-second rebuilds, independent server/client hot-reload (#3797) Enable runtime rust hot patching. * roll back wry to 0.45 * cleanup rustc * wip * wip: fix cl... — committed to DioxusLabs/dioxus by jkelleyrtp 2 years ago
- Binary patching rust hot-reloading, sub-second rebuilds, independent server/client hot-reload (#3797) Enable runtime rust hot patching. * roll back wry to 0.45 * cleanup rustc * wip * wip: fix cl... — committed to AnteDeliria/dioxus by jkelleyrtp 2 years ago
Hi there, would it be possible to revisit this?
I’m deep in the weeds of using the dynamic link system of wasm-ld and it seems like it’s wasm-bindgen that’s falling over on me.
For Dioxus 0.7 I’ve implemented
I got hot-patching working in two flavors
--pieand--experimental-picflags in conjuction with-Ctarget-cpu=mvpand-Crelocation-model=picThe table-base situation seemed to work fine but the dynamic approach has caused me all sorts of headaches. The current problem I’m facing is that the JS bindings seem to just stop working properly when loading the module, in very weird ways.
What part of wasm-bindgen would need to be overhauled to get dynamic linking and loading working in wasm?