Repository navigation
Reject delegate depth overflow in TypeChecker::OnDelegate - #2841
Merged
Merged
Conversation
sbc100
approved these changes
Aug 30, 2026
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.
wat2wasm and wasm-validate on a try...delegate with depth 0xffffffff:
Spotted wasm-validate passing a module that wasm-interp then hangs on.
TypeChecker::OnDelegateresolves the delegate target withGetLabel(depth + 1), as the depth counts from after the try being closed.depthis a u32 taken straight from the module. Fordepth == 0xffffffffthedepth + 1wraps to 0, andGetLabel(0)always succeeds, so the bounds check never fires.delegate 0xfffffffeis still rejected ("invalid depth: 4294967295 (max 2)"); only the exact wrap slips through.Downstream the interp builds the handler from
GetNearestTryLabel(depth + 1), i.e.GetNearestTryLabel(0), which returns the try being closed. The try delegates to itself, andThread::DoThrowloops on the self-referential handler.Rejecting
depth == kInvalidIndexbefore the add closes both the wat and binary paths. Every in-range delegate is untouched.