-
Notifications
You must be signed in to change notification settings - Fork 903
Description
We have been encountering the following issue when running wasmer 3.3 and wasmer 4.0 on M1 & M2:
thread 'execution' panicked at 'misaligned pointer dereference: address must be a multiple of 0x10 but is 0x109a5fc18', /Users/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-vm-4.0.0/src/trap/traphandlers.rs:219:28
rustc 1.72.0-nightly (f4b80cacf 2023-06-30)
binary: rustc
commit-hash: f4b80cacf93ca216c75f6ae12f4b9dec19eba42f
commit-date: 2023-06-30
host: aarch64-apple-darwin
release: 1.72.0-nightly
LLVM version: 16.0.5
This issue is not reproduced on:
linux_x86_64
win_x86_64
After looking into the traphandlers.rs
code, we noticed that there was a cast made towards the libc::ucontext_t
type:
let ucontext = &mut *(context as *mut libc::ucontext_t);
But the used libc::ucontext_t
is different depending on the platform, on linux we have:
libc::unix::linux_like::linux::gnu::b64::x86_64
pub struct ucontext_t // size = 936 (0x3A8), align = 0x8
Located at libc-0.2.147/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
And for mac we have:
libc::unix::bsd::apple::b64::aarch64::align
pub struct ucontext_t // size = 880 (0x370), align = 0x10
Located at libc-0.2.147/src/unix/bsd/apple/b64/aarch64/align.rs
The context that is being casted into ucontext_t
at L219
has its alignment set at 0x08
:
context: *mut c_void // size = 8, align = 0x8
This produces a misalignment between the expected 0x10
and the provided 0x08
on these types of mac architectures.
This is currently a big issue for us, if help is required we would be glad to contribute.