-
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
Add Wasmtime-specific C API functions to return errors #1467
Add Wasmtime-specific C API functions to return errors #1467
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks great! Just a nit or two and a question about how you want to deal with the .NET CI failures.
WASMTIME_DECLARE_OWN(linker) | ||
|
||
WASM_API_EXTERN own wasmtime_linker_t* wasmtime_linker_new(wasm_store_t* store); | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.h
header. 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.