I am trying to embed wasmtime using the c api and am getting this error:
failed to compile: wasm[0]::function[1]
Caused by:
0: WebAssembly translation error
1: Invalid input WebAssembly code at offset 118: unknown function 264208125: function index out of bounds
it might be a memory issue since it is coded in c but the numbers stayed constant over restarts and doesn't correspond to 0xccc... which it did with a previous memory issue.
I have attached the wasm file and the rs&toml file it came from. It was built in release mode
hello.wasm
Cargo.toml
lib.rs
note that with similar code, the following worked
hello.wasm
hello.wat
There's probably a bug in how you are using the C API, that you either haven't read the entire wasm code into memory or corrupted memory somehow. wasm-tools print ~/Downloads/hello.wasm
shows a valid wasm module for that input. if the module itself was the problem, that would give the exact same error as you see at 1, because thats wasmtime invoking the same wasmparser inside wasm-tools print
Last updated: Apr 07 2025 at 21:03 UTC