Update implementation and tests for the trap redesign#175
Conversation
See bytecodealliance#173 Currently, tests that are still failing are the following: - ExitTrapTests: It is not clear how to get the WASI exit code from a `wasmtime_error_t*` instead of an `wasmtime_trap_t*` via the C API. - FuelConsumptionTests: `wasmtime_trap_code` unexpectedly fails (SEHException) even though a trap was returned. - TrapTests: The tests introduced with bytecodealliance#172 fail as the inner exception would need to be set on the WasmtimeException instead of TrapException. Need to check how to solve this.
This moves the ExitStatus from TrapException/TrapAccessor to WasmtimeException.
… retrieve the frames for a wasmtime_error_t* using the new wasmtime_error_wasm_trace function. TODO: Add tests.
…y represent a pointer, but a platform-sized integer. Note that nint/nuint in C# will behave like regular numeric types like int/uint, so e.g. the checked/unchecked context is respected, which is not the case with IntPtr/UIntPtr until .NET 7.
…rException from the TrapException to the WasmtimeException, since host-created traps (with wasm_trap_new) are now returned as error (wasmtime_error_t*). While theoretically it could happen that the returned wasmtime_error_t* has actually another cause than the error returned at the host-to-wasm transition, I assume this is not the case, similar as to a .NET exception that would just bubble up the stack once thrown.
|
It appears that I'll try to fix this upstream. |
|
Fix upstream at bytecodealliance/wasmtime#5230. |
…trap.h header file. See GHSA-h84q-m8rr-3v9q Previously, we were passing a pointer to an Int32 (4-byte buffer), so the definition actually matched the Rust code, and therefore prior versions of wasmtime-dotnet are not impacted by that issue.
|
I added the Note: Previously, |
|
Thanks! Now that it has merged, once the dev artifact is published with that commit, I'll restart CI for this PR and merge. |
|
Sorry, I forgot to update the exception messages in the |
|
It looks like the CI is now failing for a legitimate reason in the examples, as we're currently expecting a |
|
Sorry, I hadn't thought of checking the examples. Wasmtime now seems to return the wasmtime-dotnet/tests/FuelConsumptionTests.cs Lines 85 to 89 in b7dbedf (Note however, that the I can take a look at this tomorrow, unless you beat me to it 🙂 |
|
I'll push up the fix. |
This commit updates the consume-fuel example to catch `WasmtimeException` instead of `TrapException`. The change is due to the `ConsumeFuel` call returning an error when it fails to consume the given amount of fuel and that propagates properly now.
|
Thanks again for fixing this! |
Hi, this updates the implementation and tests for the trap redesign (bytecodealliance/wasmtime#5149, bytecodealliance/wasmtime#5215).
Fixes #173
ExitCodeproperty is moved fromTrapException/TrapAccessortoWasmtimeException, as the WASI exit code now needs to be retrieved from anwasmtime_error_t*.Framesproperty is moved fromTrapExceptiontoWasmtimeException, since both errors and traps can have traces now.InnerException(see Pass original .NET callback exception asTrapException's inner exception #172) is moved from theTrapExceptionto theWasmtimeException, since host-created traps (withwasmtime_trap_new()) are now returned as error (wasmtime_error_t*).(While theoretically it could happen that the returned
wasmtime_error_t*has actually another cause than the error returned at the host-to-wasm transition, I assume this won't be the case, similar as to a .NET exception that would just bubble up the stack once thrown.)Currently, tests that are still failing are the following:
FuelConsumptionTests: Waiting for FixOutOfFueltrap code not represented in the C API. wasmtime#5230