Repository navigation
fix(runtime): return after a tail call to a host function - #509
Open
kateinoigakukun wants to merge 1 commit into
Open
kateinoigakukun wants to merge 1 commit into
kateinoigakukun wants to merge 1 commit into
Conversation
The translator emitted nothing after a tail call, so a return_call to a host function that was not the last instruction fell through into the code after it.
kateinoigakukun
force-pushed
the
fix/host-tail-call-return
branch
from
October 24, 2026 07:36
9ed44eb to
41f96ea
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
return_callto a host function ran whatever followed it in the caller's code:A tail call to a Wasm function jumps to the callee, but one to a host function comes back to the next instruction in the moved frame, which
tailInvokeexpects to return. The translator emitted nothing after a tail call (the rest is unreachable), so that only held when the tail call was the last instruction of the function. Otherwise the dead code ran in the moved, smaller frame; the resumable-call fuzzer hit it as a read below the stack (SIGBUS).The translator now emits a
_returnafter areturn_callto a host function, and after everyreturn_call_indirect/return_call_ref, whose callee is not known until it runs.return_call $hostlast in the functionreturn_call $hostfollowed by code (e.g. in ablock)return_callto a Wasm functionMetrics
wasmkit_tc_*handler, both dispatch loops,invokeandtailInvoke: byte-identical tomain(arm64 release).__TEXT: +208 B (translator only);return_call_indirect/return_call_refcode gains one slot.