Commit 54bac97
committed
fast-interp: trap on cross-function exception payload propagation
The walker's "no handler in this frame" path previously set
`prev_frame->exception_raised = true` and let `return_func`
forward the throw to the caller, regardless of payload size.
This silently lost the payload: the source cells
(`throw_src_offsets`) live in *this* frame's `frame_lp`, which
return_func is about to tear down. The caller's
`find_a_catch_handler` then ran with `throw_param_cell_num = 0`,
which made any typed catch in the caller bind uninitialized
destination slots — the catch body would either see garbage in
its payload locals or, if the typed catch's slots were used as
struct-of-pointers, dereference freed memory.
Cross-function payload preservation would require a per-thread
scratch buffer to ferry the payload across the frame boundary
(callee's frame_lp → buffer → caller's frame_lp), plus a small
change to return_func to populate it before tearing down the
callee. That's a meaningful design lift and out of scope for
this commit.
Safe action for now: when a payload-bearing throw escapes its
callee (i.e. `throw_param_cell_num > 0` and we're about to
return to a caller frame), trap to the host with the diagnostic
`"cross-function exception payload not supported by fast-
interp"`. Same-function payload routing (the common Porffor /
AS shape, where a JS throw is caught by an in-function catch
the JS-to-wasm compiler emitted) is unaffected — that path
dispatches via the same-function match in the walker before
this branch runs.
A `catch_all` in the caller would technically tolerate a
zero-payload bind, but the typed-vs-catch_all choice happens in
the caller's walker, which we can't peek into here without
coupling the frames. Trap unconditionally for payload-bearing
cross-frame throws.
Tests:
* `cross_function_tag_with_params` stays `#[ignore]` — that's
the eventual-success-case for when cross-frame payload routing
is implemented.
* `cross_function_tag_with_params_traps` (new) asserts the
current trap-with-expected-message contract on the same
module shape.
Codex P1 review feedback on
rebeckerspecialties/wasm-benchmark PR #3 (patch 0007 line 306):
"Preserve cross-frame exception payloads".1 parent 57f4169 commit 54bac97
1 file changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2083 | 2083 | | |
2084 | 2084 | | |
2085 | 2085 | | |
2086 | | - | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
2087 | 2109 | | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
2088 | 2116 | | |
2089 | 2117 | | |
2090 | 2118 | | |
| |||
0 commit comments