-
Notifications
You must be signed in to change notification settings - Fork 272
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
arm64-specific: wasm fails to instantiate: out of bounds memory access #2382
Comments
can you run this with amd64 emulation to see if it's specific to arm64? this should do it:
|
@evacchi it works under |
Perhaps still a trampoline issue? I remember when certain programs would hang in version 1.7.x and that a fix was made to the arm64 backend then. Perhaps an off-by-one of sorts is causing a memory out of bounds issue? |
@evacchi Just ran against a version with the wasm produced by go1.23.6 and it produces an identical error. |
I don't think that's what @evacchi asked for. Don't build the Wasm with 1.23, rather use 1.23 to |
@ncruces Good catch. I got that confused. @evacchi Same result unfortunately! GOTOOLCHAIN=go1.23.6 go run github.com/tetratelabs/wazero/cmd/[email protected] run ./redis-installer.wasm
go: downloading go1.23.6 (darwin/arm64)
error instantiating wasm binary: module[] function[_start] failed: wasm error: out of bounds memory access
wasm stack trace:
.time.__dataIO_.big8(i32) i32
.github.ghproxy.top_BurntSushi_toml_internal.init(i32) i32
.runtime.doInit1(i32) i32
.runtime.main(i32) i32
.wasm_pc_f_loop()
._rt0_wasm_wasip1()
exit status 1 |
interesting, so unrelated issue |
FWIW 😅
|
another "interesting" note, commenting out these lines in the frontend let it run correctly to end: wazero/internal/engine/wazevo/frontend/lower.go Lines 3668 to 3670 in c96893d
|
🤪 |
probably a red herring, I think most of what wasm-opt did in this is case is removing DWARF symbols, and with
|
ok here's what I have learned so far. In function
and it "correctly" fails. the value is loaded waaay earlier in
before the load, in post-regalloc, this appears to be block L148:
if I elide the bound check it is hard to track what truly is different because many branches obviously disappear (the bound checks themselves), some loads fold UXTW into the addressing mode, and all registers are thus different |
I don't have the technical expertise to add anything, but I just wanted to let you know that I appreciate your updates! |
upon further inspection GODEBUG=initrace=1 causes function From what I can tell from the generated code, that block has only 1 or 2 predecessors, and neither are explicitly present: but there is a table macro instruction So my suspect now is that something goes wrong in that jump table...; indeed it is a big jump table:
this in turn might be related to |
ok, some degree of progress,
we see there is a bunch of inlining happening. I tried a flag to disable inlining earlier and I didn't get any success... but it turns out the flag has changed and the one I supplied was just being ignored :D so here's the right incantation:
surprise:
and with
this is great news because I think the root cause of the issue is the same (same weird difference in crashing behavior when |
so I have some very interesting news, my old patch does not seem to have the bug #2169
in fact, while the inlined Wasm binary is ~68MB the EDIT: it's not a lot of islands, it's only 4:
|
Describe the bug
Running a wasm binary returns the error:
To Reproduce
Running on Darwin/arm64 M2 chip
Expected behavior
Expected same output as [email protected]
Environment (please complete the relevant information):
The text was updated successfully, but these errors were encountered: