Fix OutOfFuel trap code not represented in the C API. (#5230)

This commit adds the missing "out of fuel" trap code to the C API.

Without this, calls to `wasmtime_trap_code` will trigger an unreachable panic
on traps from running out of fuel.
This commit is contained in:
Peter Huene
2022-11-10 12:42:26 -08:00
committed by GitHub
parent 3b9668558f
commit 42e88c7b24
4 changed files with 11 additions and 1 deletions

View File

@@ -100,6 +100,11 @@ int main() {
wasmtime_val_t results[1];
error = wasmtime_func_call(context, &fib.of.func, params, 1, results, 1, &trap);
if (error != NULL || trap != NULL) {
if (trap != NULL) {
wasmtime_trap_code_t code;
assert(wasmtime_trap_code(trap, &code));
assert(code == WASMTIME_TRAP_CODE_OUT_OF_FUEL);
}
printf("Exhausted fuel computing fib(%d)\n", n);
break;
}