As of Rust v1.70, exporting a function like this:
#[wasm_bindgen]
pub fn test(_: &[u64]) {}
... will make it panic when called from JS:
panicked at 'misaligned pointer dereference: address must be a multiple of 0x8 but is 0x4'
Here is a minimal reproducible example:
https://github.com/daxpedda/wasm-bindgen-bigint-slice-issue
I confirmed the following scenarios:
- Only
u64 and i64 integer types cause this issue.
- Rust v1.69 does not have this issue.
- The recent Rust changelog doesn't note any significant changes other then the upgrade to LLVM 16, which added default target features to Wasm:
- Compiling with
-Ctarget-feature=-sign-ext,-mutable-globals and -Zbuild-std on nightly-2023-06-03 does not fix the issue.
- Compiling with
-Ctarget-feature=+sign-ext,+mutable-globals on Rust v1.69 does not cause this issue.
This issue was originally discovered here: https://github.com/rustwasm/wasm-bindgen/actions/runs/5176047134/jobs/9324382988#step:7:409.
Update: apparently the bug is coming from rust-lang/rust#98112.
It's possible to circumvent the check by just disabling debug_asserts.
As of Rust v1.70, exporting a function like this:
... will make it panic when called from JS:
Here is a minimal reproducible example:
https://github.com/daxpedda/wasm-bindgen-bigint-slice-issue
I confirmed the following scenarios:
u64andi64integer types cause this issue.-Ctarget-feature=-sign-ext,-mutable-globalsand-Zbuild-stdon nightly-2023-06-03 does not fix the issue.-Ctarget-feature=+sign-ext,+mutable-globalson Rust v1.69 does not cause this issue.This issue was originally discovered here: https://github.com/rustwasm/wasm-bindgen/actions/runs/5176047134/jobs/9324382988#step:7:409.
Update: apparently the bug is coming from rust-lang/rust#98112.
It's possible to circumvent the check by just disabling
debug_asserts.