-
Notifications
You must be signed in to change notification settings - Fork 813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misaligned pointer dereference on Mac M1 Pro & Mac M2 Pro #4072
Comments
we're also hitting this in 2.3.0 in anoma/namada#1721 |
Might be related: #4059 |
Get same error on M1 16GB with |
Note that this is likely becoming visible due to rust-lang/rust#98112 landing in Rust 1.70, which adds debug assertions to misaligned pointer dereferences. It's possible that macOS does not guarantee this pointer is going to be 16 byte aligned even though a structure within it (the NEON floating point state) is nominally supposed to be. I can't easily find anything about it, you might end up having to file a radar about it. I am sure you can work around it writing out your own less-aligned structure to cast to, though, but that's obviously not fun. |
Hi, In the original issue it's not an assert that fails. AFAIK, for the cast to work one need looking at https://github.com/rust-lang/libc/blob/main/src/unix/bsd/apple/b64/aarch64/align.rs If this is correct (don't' have M1 or M2 so I can't try) this seems to be a dead end, but this would lead me to think that on such platform * c_void should be aligned to 16, so maybe there is something to look on the rust std side. Looking at https://doc.rust-lang.org/beta/core/ffi/enum.c_void.html# I found this
Regards |
I was able to hack a fix to this issue, based on the research presented in this thread. sug0@df6aa26#diff-5d272e62ff3e9e2d5249a6300df4eb51eeb019e143582bfe8f93d7cd3674d176R150-R168 If anyone has some free time, please test the patch. The branch ( Cheers, |
The fix looks fine, and I can implement it. The issue is, how can I reproduce the issue, there is no simple way to have it seems? |
@sug0 do you plan to create a PR based on current master fr this fix? |
@ptitSeb |
I have the hardware, but not a simple way to reproduce the issue. |
We have code that fails here. Edit: |
@bilboquet can you test with that branch #4120 |
@ptitSeb yes sure, will do this with my teammate who has the hardware |
@bilboquet any news on the fix efficiency? |
@ptitSeb not tested yet, will do this week |
Ok, closing the issue! |
@Eitu33, do you have a PoC to reproduce the issue in wasmer 3.3 or wasmer 4.0? thanks. |
@junxzm1990 No, the issue was reproduced in a relatively complex scenario. I could make a PoC but I'm not sure I can find the time / get the clearance to do so. What I work on is open source so If you really want to reproduce the issue I could make a branch on our repo with everything setup to reproduce, but that would be very far from a minimal example. |
@Eitu33, A repo for reproduction would be greatly appreciated. I can follow up on the repo attempting to create a simpler PoC. |
Hello. I've tried to experiment with some thinks, but I think I've got MRE of exact same problem. Wasm module code:
Dependencies:
Build with: And host part is:
Panics:
I've also tried to find what exactly causes panic on module side, so:
|
We have been encountering the following issue when running wasmer 3.3 and wasmer 4.0 on M1 & M2:
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 thelibc::ucontext_t
type:But the used
libc::ucontext_t
is different depending on the platform, on linux we have:Located at
libc-0.2.147/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
And for mac we have:
Located at
libc-0.2.147/src/unix/bsd/apple/b64/aarch64/align.rs
The context that is being casted into
ucontext_t
atL219
has its alignment set at0x08
:This produces a misalignment between the expected
0x10
and the provided0x08
on these types of mac architectures.This is currently a big issue for us, if help is required we would be glad to contribute.
The text was updated successfully, but these errors were encountered: