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

RuntimeError is not always downcastable to the host error #1328

Closed
MaksymZavershynskyi opened this issue Mar 23, 2020 · 2 comments · Fixed by #1401
Closed

RuntimeError is not always downcastable to the host error #1328

MaksymZavershynskyi opened this issue Mar 23, 2020 · 2 comments · Fixed by #1401
Labels
bug Something isn't working

Comments

@MaksymZavershynskyi
Copy link

Describe the bug

In Rust, sometimes wasmer_runtime::error::RuntimeError returned by Wasmer is not downcast-able to the error type that our host function returns to Wasmer.

Versions:

wasmer-runtime = { version = "0.11.0", features = ["default-backend-singlepass"], default-features = false }
wasmer-runtime-core = { version = "0.11.0", features = ["backend-singlepass"]}

Expected behavior

RuntimeError to be always downcastable to the error returned by the host functions.

Actual behavior

Sometimes we are getting error that cannot be downcasted.

@MarkMcCaskey
Copy link
Contributor

Thanks for the bug report!

I believe RuntimeError is returned in other exceptional situations to avoid panicking or terminating, for example: in Func::call.

It seems that when an internal RuntimeError is returned, it's usually either a &'static str or a String. I'd be curious to know if the errors you're seeing can be downcast to either of those and if so, what the message is.

Additionally since, 0.14.0 it looks like we sometimes return an ExceptionCode this way.

@MaksymZavershynskyi
Copy link
Author

Will try to reproduce

bors bot added a commit that referenced this issue Apr 28, 2020
1401: Make runtime and trap errors well defined r=syrusakbary a=MarkMcCaskey

Resolves #1328 

This PR goes through and gives explicit types for all the errors instead of using `Box<dyn Any + Send>` where possible.  This gives users better insight into what the specific errors are and should help with debugging in the case of mistakes in our code.

The remaining uses of `Box<dyn Any>` are due to the structure of our dependency graph -- this is probably solvable but it seems fine as is as all error types are now explicit and the remaining `Box<dyn Any>`s are either fully user controlled or not for end-user consumption.

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <[email protected]>
@bors bors bot closed this as completed in d23a3f3 Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants