Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASI proc_exit throws exception instead of returning error code #361

Closed
kanaka opened this issue Apr 16, 2019 · 2 comments
Closed

WASI proc_exit throws exception instead of returning error code #361

kanaka opened this issue Apr 16, 2019 · 2 comments
Labels
bug Something isn't working 📦 lib-wasi About wasmer-wasi

Comments

@kanaka
Copy link

kanaka commented Apr 16, 2019

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.

@kanaka kanaka added the bug Something isn't working label Apr 16, 2019
@kanaka
Copy link
Author

kanaka commented Apr 20, 2019

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

@bjfish bjfish added the 📦 lib-wasi About wasmer-wasi label Apr 21, 2019
bors bot added a commit that referenced this issue Apr 23, 2019
383: Hook up wasi exit code to wasmer cli r=lachlansneff a=lachlansneff

Test by running:

```
> target/release/wasmer run examples/exit.wat
> echo $?
```

should echo "7".

Fixes (at least the exit code part) of #361.

Co-authored-by: Lachlan Sneff <[email protected]>
@kanaka
Copy link
Author

kanaka commented May 3, 2019

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

@kanaka kanaka closed this as completed May 3, 2019
surban pushed a commit to rust-wasi-web/wwrr that referenced this issue Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📦 lib-wasi About wasmer-wasi
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants