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

Improve debuggability by adding original host function exceptions to TrapException #63

Closed
peterhuene opened this issue Jun 15, 2021 · 1 comment · Fixed by #172
Closed
Labels
enhancement New feature or request

Comments

@peterhuene
Copy link
Member

Right now if a host function throws a .NET exception, the exception is caught and translated to a trap representation.

The trap representation only keeps the exception message. When the trap bubbles back up to .NET, the trap is thrown as a TrapException.

Since only the message is kept, debugging the source of the host function exception can be difficult, especially from a log that prints only the TrapException.

When a trap representation is created, the original caught exception should be stored somewhere that can be utilized from where TrapException is thrown and passed in as the inner exception.

@alexhiggins732
Copy link
Contributor

I am currently in this area of code in PR #95 and not sure what else can be done here.

We are already capturing the web assembly error message as a string and work has already been done to utilize the methods within the c bindings in trap.h to walk the stack:

Functions:

wasm_trap_t * wasmtime_trap_new (const char *msg, size_t msg_len)
Creates a new trap. More...

bool wasmtime_trap_code (const wasm_trap_t *, wasmtime_trap_code_t *code)
Attempts to extract the trap code from this trap. More...

bool wasmtime_trap_exit_status (const wasm_trap_t *, int *status)
Attempts to extract a WASI-specific exit status from this trap. More...

const wasm_name_t * wasmtime_frame_func_name (const wasm_frame_t *)
Returns a human-readable name for this frame's function. More...

const wasm_name_t * wasmtime_frame_module_name (const wasm_frame_t *)
Returns a human-readable name for this frame's module. More...

Please let me know if there was something else you had in mind.

kpreisser added a commit to kpreisser/wasmtime-dotnet that referenced this issue Oct 29, 2022
…ion of the TrapException when the trap bubbles up to the next host-to-wasm transition.

Fixes bytecodealliance#63
kpreisser added a commit to kpreisser/wasmtime-dotnet that referenced this issue Oct 29, 2022
…ion of the TrapException when the trap bubbles up to the next host-to-wasm transition.

Fixes bytecodealliance#63
peterhuene pushed a commit that referenced this issue Nov 2, 2022
…ption (#172)

* Pass exceptions caught at the wasm-to-host transition as inner exception of the TrapException when the trap bubbles up to the next host-to-wasm transition.

Fixes #63

* Follow-Up: Use nuint insteadof UIntPtr for size_t parameters.

* Update tests and comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants