Error: failed to run main module when executing WebAssembly module processed with `wasm-opt --remove-memory` in wasm runtime
Uh5GoKGJ9X opened this issue · comments
Hello,
I attempted to process a file test.wasm using wasm-opt
with --remove-memory
option, which generated test.opt.wasm
. When trying to execute it in the wasmtime
runtime, I encountered the following error:
$ wasmtime ./test.wasm
16871285034349708082
$ wasm-opt ./test.wasm --remove-memory -o ./test.opt.wasm
$ wasmtime ./test.opt.wasm
Error: failed to run main module `./test.opt.wasm`
Caused by:
0: failed to invoke command default
1: error while executing at wasm backtrace:
0: 0xb6 - <unknown>!<wasm function 7>
1: 0xc3 - <unknown>!<wasm function 6>
2: 0xcb - <unknown>!<wasm function 8>
2: memory fault at wasm address 0xfffffffa in linear memory of size 0x80000
3: wasm trap: out of bounds memory access
Environment Information:
wasm-opt
version:
wasm-opt version 117 (version_117-31-g6e8fefe1e)
wasmtime
version:
wasmtime-cli 18.0.3 (ff528a2ba 2024-03-12)
Operating System:
Ubuntu 20.04.6 LTS
That looks like the expected behavior. The wasm module is doing a store to address $2 = $0 - $1 = 0 - 6 = -6
which is a very large unsigned number, well beyond the Memory which is just 8 pages of 64K.
(--remove-memory
does not affect this, as it only removes memory segments, and there are none)