WebAssembly / WebAssembly/WASI
Whether validate exit status for proc_exit is needed
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.8k
- Forks
- 333
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 3
Description
Recently, while executing the same wasm file with different wasm runtime tools, the obtained results were different. Here are related files.
The given testcase simply mutated a wasm file, which was obtained by compiling C program generated with Csmith using Emscripten Compiler(Emcc).
The original C program is c_file.c, the compilation results with Emscripten is wasm_file.wasm, and its wat format is wat_file.wat.
We mutated the wat file to change its global.set 0 in line 7627 with local.set 0. The result after mutation is mutated_file.wat, and its wasm format is mutated_file.wasm.
We use runtime tools such as wasmer, wasmtime, wasmedge and wasmi to execute mutated_file.wasm. Wasmtime outputs checksum results with runtime error, while other tools only output checksum results. The execution results of different tools are shown in the following figure.
It seems that tools such as wasmtime and wasmi validate exit status, while other tools do not. Mutation makes the provided status isn't in the printed range, resulting in runtime error for tools like wasmtime when outputting checksum results.
The current documentation for proc_exit does not exactly specify what to do here. So I wonder whether this behavior is still desired and/or should be codified in the documentation.
If not wasmtime should remove it. If so other runtimes should be updated. Thanks a lot!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with legacy/preview1/witx/wasi_snapshot_preview1.witx lines 460-467 and reproduce the behavior using the linked mutated_file.wasm across the named runtimes. Compare how proc_exit status is handled and determine whether the specification needs clarification. Done means the intended behavior is decided and codified in the documentation, or the issue is resolved with the required runtime changes identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100