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

"RuntimeError: out of bounds memory access" (C++ -> Wasm via Enscripten) #5324

Open
KieranP opened this issue Jan 4, 2025 · 1 comment
Open

Comments

@KieranP
Copy link

KieranP commented Jan 4, 2025

Describe the bug

I'm using enscripten to convert a C++ project (https://github.com/KieranP/Game-Of-Life-Implementations/tree/master/c%2B%2B) into WASM, and then using wasmer to run it. Compiling/running the application as C++ has no issues and enscripten reports no issues converting to wasm. When running with wasmer, am getting unexpected "RuntimeError: out of bounds memory access" errors.

wasmer 5.0.4 (??????? 2024-12-17)
binary: wasmer-cli
commit-hash: 
commit-date: 2024-12-17
host: aarch64-apple-darwin
compiler: cranelift
c_api backend: 

rustc 1.83.0 (90b35a623 2024-11-26) (Homebrew)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: aarch64-apple-darwin
release: 1.83.0
LLVM version: 19.1.6

Steps to reproduce

$ emcc -o play.wasm play.cpp
$ wasmer run play.wasm     
error: RuntimeError: out of bounds memory access
╰─▶ 1: RuntimeError: out of bounds memory access

Expected behavior

Should run without error. Errors should also indicate the cause a bit more clearly.

Actual behavior

Throws error that doesn't exist when running as C++ project. Location of out of bounds memory access unknown.

@KieranP
Copy link
Author

KieranP commented Jan 4, 2025

If I change play.cpp lines 19-21 from:

      if (!minimal) {
        cout << world->render();
      }

to

      if (!minimal) {
        cout << world->render();
        cout << "here?";
      }

it executes the first cout call, but not the second.

So somewhere after successfully calling cout << world->render();, something is getting messed up before it reaches the next line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant