The WASI proc_exit function causes an exception to be raised and does not set the requested error code.
The following wat code:
(module
(import "wasi_unstable" "proc_exit" (func $proc_exit (param i32)))
(memory 10)
(export "memory" (memory 0))
(func $main
(call $proc_exit (i32.const 7))
)
(start $main)
)
Results in the following behavior with wasmer 0.3.0:
$ ~/.wasmer/bin/wasmer run wasitests/exit.wasm
"Can\'t instantiate module: CallError(RuntimeError: Instance exited)"
$ echo $?
1
There should be no exception and the result error code should be set to the argument value. In the example above the exit code value should be 7.
Exception with return value of 1.
I checked again and the error message is different but the behavior is still the same:
$ wasmer run wasitests/exit.wasm
"RuntimeError: WebAssembly trap occured during runtime: unknown"
$ echo $?
1
I checked wasmer 0.4.0 and this appears to be resolved. Thanks!
Most helpful comment
I checked wasmer 0.4.0 and this appears to be resolved. Thanks!