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

Allow reporting errors when loading wasm modules into .NET #7

Closed
cgranade opened this issue Mar 7, 2020 · 2 comments · Fixed by #15
Closed

Allow reporting errors when loading wasm modules into .NET #7

cgranade opened this issue Mar 7, 2020 · 2 comments · Fixed by #15
Assignees

Comments

@cgranade
Copy link

cgranade commented Mar 7, 2020

Feature

When loading wasm modules into .NET with wasmtime, an exception is raised if a module is invalid. This exception doesn't provide any details as to what went wrong, however, making it hard to fix the module.

Implementation

The .NET implementation relies on the wasm_module_new function.
https://github.com/bytecodealliance/wasmtime/blob/121bbd36568c506a39b2dd97a95dd2b963960eb7/crates/c-api/src/lib.rs#L828

This function currently discards the error information with a match expression:

https://github.com/bytecodealliance/wasmtime/blob/121bbd36568c506a39b2dd97a95dd2b963960eb7/crates/c-api/src/lib.rs#L836

Allowing this information to be captured in a callback or in a mutable pointer to a string that could capture the Debug derive for the anyhow::Error would be helpful in diagnosing errors that occur when loading modules.

@peterhuene peterhuene transferred this issue from bytecodealliance/wasmtime Apr 7, 2020
@peterhuene
Copy link
Member

This should now be possible to fix with bytecodealliance/wasmtime#1467 merged. We can get validation errors by using the wasmtime_module_new API.

@cgranade
Copy link
Author

cgranade commented Apr 7, 2020

Awesome, thank you for the update!

@peterhuene peterhuene self-assigned this Apr 22, 2020
peterhuene added a commit to peterhuene/wasmtime-dotnet that referenced this issue Jun 6, 2020
This commit replaces the use of `wasm_module_new` with `wasmtime_module_new`
which can include the error message for failing to load the module.

Fixes bytecodealliance#7.
peterhuene added a commit to peterhuene/wasmtime-dotnet that referenced this issue Jun 10, 2020
This commit replaces the use of `wasm_module_new` with `wasmtime_module_new`
which can include the error message for failing to load the module.

Fixes bytecodealliance#7.
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