Add Wasmtime-specific C API functions to return errors#1467
Add Wasmtime-specific C API functions to return errors#1467alexcrichton merged 8 commits intobytecodealliance:masterfrom
Conversation
This commit adds new `wasmtime_*` symbols to the C API, many of which mirror the existing counterparts in the `wasm.h` header. These APIs are enhanced in a number of respects: * Detailed error information is now available through a `wasmtime_error_t`. Currently this only exposes one function which is to extract a string version of the error. * There is a distinction now between traps and errors during instantiation and function calling. Traps only happen if wasm traps, and errors can happen for things like runtime type errors when interacting with the API. * APIs have improved safety with respect to embedders where the lengths of arrays are now taken as explicit parameters rather than assumed from other parameters.
Subscribe to Label ActionThis issue or pull request has been labeled: "wasmtime:api", "wasmtime:c-api", "wasmtime:docs" Users Subscribed to "wasmtime:api"Users Subscribed to "wasmtime:c-api"To subscribe or unsubscribe from this label, edit the |
Subscribe to Label ActionThis issue or pull request has been labeled: "fuzzing" Users Subscribed to "fuzzing"To subscribe or unsubscribe from this label, edit the |
peterhuene
left a comment
There was a problem hiding this comment.
👍 Looks great! Just a nit or two and a question about how you want to deal with the .NET CI failures.
| WASM_API_EXTERN void wasmtime_linker_allow_shadowing(wasmtime_linker_t* linker, bool allow_shadowing); | ||
|
|
||
| WASM_API_EXTERN bool wasmtime_linker_define( | ||
| WASM_API_EXTERN own wasmtime_error_t* wasmtime_linker_define( |
There was a problem hiding this comment.
This (and the similar changes above) is the source of the .NET CI failures since it's now the inverse of what the .NET code is expecting (i.e. return value of 0 is now success rather than failure).
As I'm now moving the .NET code to wasmtime-dotnet, so we just merge this in with failing CI and fix it there or do you want to get this CI green and I'll port the fix to the other repo?
There was a problem hiding this comment.
Indeed! Mind double-checking my C# to confirm that what's there is reasonable?
(it's somewhat intentionally not fully fleshed out in every spot since I figured you'll want to tweak APIs further as well)
peterhuene
left a comment
There was a problem hiding this comment.
LGTM! 👍
Just the one comment regarding the null termination of wasmtime error messages.
This commit adds new
wasmtime_*symbols to the C API, many of whichmirror the existing counterparts in the
wasm.hheader. These APIs areenhanced in a number of respects:
Detailed error information is now available through a
wasmtime_error_t. Currently this only exposes one function which isto extract a string version of the error.
There is a distinction now between traps and errors during
instantiation and function calling. Traps only happen if wasm traps,
and errors can happen for things like runtime type errors when
interacting with the API.
APIs have improved safety with respect to embedders where the lengths
of arrays are now taken as explicit parameters rather than assumed
from other parameters.