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

Is it possible to resume after a panic? #1049

Closed
Michael-F-Bryan opened this issue Dec 9, 2019 · 2 comments · Fixed by #1053
Closed

Is it possible to resume after a panic? #1049

Michael-F-Bryan opened this issue Dec 9, 2019 · 2 comments · Fixed by #1053
Assignees
Labels
❓ question I've a question!

Comments

@Michael-F-Bryan
Copy link
Contributor

I know the wasmer runtime will detect when a host function (i.e. something passed in using imports!()) panics and translate that to a RuntimeError (presumably around here). Is it possible for the top-level caller to use std::panic::resume_unwind() to continue panicking?

The data in RuntimeError::Error is Box<Any>, whereas std::panic::resume_unwind() expects Box<dyn Any + Send>.

I guess one possible solution is to match on the result of call() and then explicitly panic!() if a runtime error was detected. That would let us continue crashing, but would also mean we lose the original backtrace.

This may be related to #986 or #827.

@Michael-F-Bryan Michael-F-Bryan added the ❓ question I've a question! label Dec 9, 2019
@nlewycky nlewycky self-assigned this Dec 10, 2019
@nlewycky
Copy link
Contributor

I think as a library we don't want to take down the program that's using us by default, though we should make it easy to turn that RuntimeError back into a panic! with the stack information if, as the host program, that's what you want to do.

Maybe it's as simple as making RuntimeError::Error a Box<Any + Send>?

@Michael-F-Bryan
Copy link
Contributor Author

I think it would be. Or maybe add an extra HostFunctionPanicked(Box<dyn Any + Send>) variant to RuntimeError? That way you won't accidentally try to resume a Box<dyn Any + Send> which isn't actually a panic, and can differentiate between whether a function panicked or just returned an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question I've a question!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants