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

Wasmtime C API: Missing way to retrieve the WASI exit code when using wasmtime_func_call_unchecked #5257

Closed
kpreisser opened this issue Nov 12, 2022 · 1 comment · Fixed by #5262

Comments

@kpreisser
Copy link
Contributor

kpreisser commented Nov 12, 2022

Hi!

As far as I understand the trap redesign with #5149 regarding the C API, host traps/errors created with wasmtime_trap_new, as well as traps caused by setting the WASI exit code (by calling WASI's proc_exit), are now returned as wasmtime_error_t* instead of wasm_trap_t* (e.g. with wasmtime_func_call and wasmtime_linker_instantiate); whereas normally only actual WASM traps that have a corresponding trap code (wasmtime_trap_code_t) are still returned as wasm_trap_t*.

With #5215, the WASI exit code can now be retrieved from the wasmtime_error_t*.

However, the unchecked variant wasmtime_func_call_unchecked only returns a wasm_trap_t*, but no wasmtime_error_t*. Therefore, it doesn't seem possible e.g. to extract the WASI exit code from it:

WASM_API_EXTERN wasm_trap_t *wasmtime_func_call_unchecked(
wasmtime_context_t *store,
const wasmtime_func_t *func,
wasmtime_val_raw_t *args_and_results
);

Would this require an adjustment of the C API? E.g., should wasmtime_func_call_unchecked additionally return a wasmtime_error_t*, for consistency with wasmtime_func_call, so that it would return host traps and WASI exit traps as wasmtime_error_t*, instead of wasm_trap_t*?

Thanks!

@alexcrichton
Copy link
Member

Oh dear you are right, thanks for the report! I'll work on updating this API today to return the error/trap combo. I think the error/trap combo probably needs to be redone in the future since it makes less sense than it did before, but in the meantime no functionality should be lost with this prior refactoring.

alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Nov 14, 2022
Change the return value of this function to a `wasmtime_error_t*`
instead of the prior `wasm_trap_t*`. This is a leftover from bytecodealliance#5149.

Closes bytecodealliance#5257
alexcrichton added a commit that referenced this issue Nov 14, 2022
…5262)

Change the return value of this function to a `wasmtime_error_t*`
instead of the prior `wasm_trap_t*`. This is a leftover from #5149.

Closes #5257
alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Nov 14, 2022
…ytecodealliance#5262)

Change the return value of this function to a `wasmtime_error_t*`
instead of the prior `wasm_trap_t*`. This is a leftover from bytecodealliance#5149.

Closes bytecodealliance#5257
alexcrichton added a commit that referenced this issue Nov 14, 2022
…5262) (#5263)

Change the return value of this function to a `wasmtime_error_t*`
instead of the prior `wasm_trap_t*`. This is a leftover from #5149.

Closes #5257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants