Wasmer: WASI proc_exit throws exception instead of returning error code

Created on 16 Apr 2019  路  2Comments  路  Source: wasmerio/wasmer

Describe the bug

The WASI proc_exit function causes an exception to be raised and does not set the requested error code.

Steps to reproduce

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

Expected behavior

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.

Actual behavior

Exception with return value of 1.

馃悶 bug 馃摝 lib-wasi

Most helpful comment

I checked wasmer 0.4.0 and this appears to be resolved. Thanks!

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings