-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update how exits are modeled in the C API #5215
Merged
alexcrichton
merged 1 commit into
bytecodealliance:main
from
alexcrichton:update-c-api-traps
Nov 7, 2022
Merged
Update how exits are modeled in the C API #5215
alexcrichton
merged 1 commit into
bytecodealliance:main
from
alexcrichton:update-c-api-traps
Nov 7, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously extracting an exit code was only possibly on a `wasm_trap_t` which will never successfully have an exit code on it, so the exit code extractor is moved over to `wasmtime_error_t`. Additionally extracting a wasm trace from a `wasmtime_error_t` is added since traces happen on both traps and errors now.
As a note to myself, I want to test this against our C-API-based bindings and then if this is sufficient this'll need a backport to the 3.0.0 branch before release. |
Subscribe to Label Actioncc @peterhuene
This issue or pull request has been labeled: "wasmtime:c-api"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
pchickey
approved these changes
Nov 7, 2022
kpreisser
added a commit
to kpreisser/wasmtime-dotnet
that referenced
this pull request
Nov 7, 2022
This moves the ExitStatus from TrapException/TrapAccessor to WasmtimeException.
alexcrichton
added a commit
to alexcrichton/wasmtime
that referenced
this pull request
Nov 8, 2022
Previously extracting an exit code was only possibly on a `wasm_trap_t` which will never successfully have an exit code on it, so the exit code extractor is moved over to `wasmtime_error_t`. Additionally extracting a wasm trace from a `wasmtime_error_t` is added since traces happen on both traps and errors now.
alexcrichton
added a commit
that referenced
this pull request
Nov 8, 2022
* c-api: Avoid losing error context with instance traps This commit was a mistake from #5149 * Update how exits are modeled in the C API (#5215) Previously extracting an exit code was only possibly on a `wasm_trap_t` which will never successfully have an exit code on it, so the exit code extractor is moved over to `wasmtime_error_t`. Additionally extracting a wasm trace from a `wasmtime_error_t` is added since traces happen on both traps and errors now.
peterhuene
added a commit
to bytecodealliance/wasmtime-dotnet
that referenced
this pull request
Nov 10, 2022
* Update some tests for the new trap behavior. See #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 #172 fail as the inner exception would need to be set on the WasmtimeException instead of TrapException. Need to check how to solve this. * Update for the changes in bytecodealliance/wasmtime#5215. This moves the ExitStatus from TrapException/TrapAccessor to WasmtimeException. * Follow-Up: Add a Frames property to WasmtimeException which allows to retrieve the frames for a wasmtime_error_t* using the new wasmtime_error_wasm_trace function. TODO: Add tests. * Use nuint instead of UIntPtr for sizes (size_t) as they don't actually 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. * Move the functionality of passing the original .NET exception as InnerException 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. * Fix the definition of wasmtime_trap_code to match the signature from 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. * Add TrapCode.OutOfFuel. See bytecodealliance/wasmtime#5230 * Follow-Up: Update for the changed exception message. * Update the consume-fuel example. 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. Co-authored-by: Peter Huene <phuene@fastly.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously extracting an exit code was only possibly on a
wasm_trap_t
which will never successfully have an exit code on it, so the exit code extractor is moved over towasmtime_error_t
. Additionally extracting a wasm trace from awasmtime_error_t
is added since traces happen on both traps and errors now.