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

Handling the exit trap #30

Closed
whitequark opened this issue Jun 21, 2020 · 4 comments · Fixed by #35
Closed

Handling the exit trap #30

whitequark opened this issue Jun 21, 2020 · 4 comments · Fixed by #35

Comments

@whitequark
Copy link
Contributor

Since wasmtime-py 0.18.0, it seems that when the main() function returns, the call to _start() also simply returns, which is good. However, it looks like if exit() is called, then the result is a wasmtime._trap.Trap: Exited with i32 exit status 1. It is not clear how this trap can be handled besides matching the exception message with a regex.

@whitequark whitequark changed the title Different behavior for returning from main() and calling exit() Handling the exit trap Jun 21, 2020
@whitequark
Copy link
Contributor Author

It looks like I am mistaken; the only change in behavior is that nonzero exit codes result in a trap now. That's great, actually! But I'd still need some nice way to handle the trap.

@whitequark
Copy link
Contributor Author

After more testing I think my original conclusion was accurate; I later dismissed it because wasmtime 0.17 had another issue, which is that it looks like setting argv doesn't work at all.

@alexcrichton
Copy link
Member

Ah yes, I'll add C API functions for inspecting this so a new exception class can be implemented here.

alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Jun 23, 2020
This allows embedders to take a different action when a WASI program
exits depending on whether it exited with an exit status or exited with
a trap.

cc bytecodealliance/wasmtime-py#30
alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Jun 23, 2020
This allows embedders to take a different action when a WASI program
exits depending on whether it exited with an exit status or exited with
a trap.

cc bytecodealliance/wasmtime-py#30
alexcrichton added a commit to bytecodealliance/wasmtime that referenced this issue Jun 23, 2020
This allows embedders to take a different action when a WASI program
exits depending on whether it exited with an exit status or exited with
a trap.

cc bytecodealliance/wasmtime-py#30
alexcrichton added a commit to alexcrichton/wasmtime-py that referenced this issue Jun 23, 2020
* Add an `ExitTrap` subclass of `Trap`
* Return an appropriate trap from `Trap.__from_ptr__`
* Attach the exit code via a `code` field

Closes bytecodealliance#30
alexcrichton added a commit to alexcrichton/wasmtime-py that referenced this issue Jun 23, 2020
* Add an `ExitTrap` subclass of `Trap`
* Return an appropriate trap from `Trap.__from_ptr__`
* Attach the exit code via a `code` field

Closes bytecodealliance#30
@alexcrichton
Copy link
Member

Ok I've added bindings for this at #35

alexcrichton added a commit that referenced this issue Jun 23, 2020
* Add an `ExitTrap` subclass of `Trap`
* Return an appropriate trap from `Trap.__from_ptr__`
* Attach the exit code via a `code` field

Closes #30
jedisct1 pushed a commit to jedisct1/wasmtime-crypto that referenced this issue Jul 2, 2020
This allows embedders to take a different action when a WASI program
exits depending on whether it exited with an exit status or exited with
a trap.

cc bytecodealliance/wasmtime-py#30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants