Skip to content

Exporting bigint slices panics #3461

Closed
@daxpedda

Description

@daxpedda

As of Rust v1.70, exporting a function like this:

#[wasm_bindgen]
pub fn test(_: &[u64]) {}

... will make it panic when called from JS:

test([]);
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.

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