Skip to content
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

Open
davidmdm opened this issue Feb 22, 2025 · 8 comments
Open
Labels
bug Something isn't working

Comments

@davidmdm
Copy link
Contributor

Describe the bug
Running a wasm binary returns the error:

error instantiating wasm binary: module[] function[_start] failed: wasm error: out of bounds memory access
wasm stack trace:
        .time.__dataIO_.big8(i32) i32
        .github.com_BurntSushi_toml_internal.init(i32) i32
        .runtime.doInit1(i32) i32
        .runtime.main(i32) i32
        .wasm_pc_f_loop()
        ._rt0_wasm_wasip1()

To Reproduce
Running on Darwin/arm64 M2 chip

set -x

if [ ! -d "yoke" ]; then
  git clone --depth=1 https://github.com/yokecd/yoke.git
fi

(
  cd yoke
  GOOS=wasip1 GOARCH=wasm go build -o ../redis-installer.wasm ./examples/redis
)

# will run successfully
go run github.com/tetratelabs/wazero/cmd/[email protected] run ./redis-installer.wasm

# will fail with aforementioned error
go run github.com/tetratelabs/wazero/cmd/[email protected] run ./redis-installer.wasm

Expected behavior
Expected same output as [email protected]

Environment (please complete the relevant information):

  • Go version: 1.24.0
  • wazero Version: 1.9.0
  • Host architecture: arm64
  • Runtime mode: compiler
@davidmdm davidmdm added the bug Something isn't working label Feb 22, 2025
@evacchi
Copy link
Contributor

evacchi commented Feb 24, 2025

can you run this with amd64 emulation to see if it's specific to arm64? this should do it:

GOARCH=amd64 go run github.com/tetratelabs/wazero/cmd/[email protected] run ./redis-installer.wasm

@davidmdm
Copy link
Contributor Author

@evacchi it works under amd64 emulation. So its a bug specific to arm64!

@davidmdm davidmdm changed the title wasm fails to instantiate: out of bounds memory access arm64-specific: wasm fails to instantiate: out of bounds memory access Feb 24, 2025
@davidmdm
Copy link
Contributor Author

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
Copy link
Contributor

evacchi commented Feb 25, 2025

@davidmdm out of curiosity, have you tried against Go 1.23? let's rule out something related to #2375

@davidmdm
Copy link
Contributor Author

@evacchi Just ran against a version with the wasm produced by go1.23.6 and it produces an identical error.
I checked the new wasm did not match the one produced by go1.24.0 as well to be sure.

@ncruces
Copy link
Contributor

ncruces commented Feb 25, 2025

I don't think that's what @evacchi asked for. Don't build the Wasm with 1.23, rather use 1.23 to go run wazero.

@davidmdm
Copy link
Contributor Author

@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.com_BurntSushi_toml_internal.init(i32) i32
        .runtime.doInit1(i32) i32
        .runtime.main(i32) i32
        .wasm_pc_f_loop()
        ._rt0_wasm_wasip1()
exit status 1

@evacchi
Copy link
Contributor

evacchi commented Feb 26, 2025

interesting, so unrelated issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants