Fix long validation of array.new-fixed in unreachable code - #2688
Merged
alexcrichton merged 2 commits intoSep 29, 2026
Merged
Conversation
This commit fixes an issue in `wasmparser` where validation of `array.new-fixed` in unreachable code would take `O(n)` time where `n` was the immediate on `array.new-fixed`. It's valid for unreachable code to have `array.new-fixed $a 0xff..ff` for example because `unreachable` is polymorphic in its stack, but wasmparser's previous implementation would pop each individual operand from the stack (getting `MaybeType::Bottom` a low), and this took time linear to the magnitude of the immediate as opposed to linear in the size of the code itself. This meant it was pretty easy to generate a small module that takes ~forever to validate, which generally is not a property we want to have.
pchickey
approved these changes
Sep 29, 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.
This commit fixes an issue in
wasmparserwhere validation ofarray.new-fixedin unreachable code would takeO(n)time wherenwas the immediate onarray.new-fixed. It's valid for unreachable code to havearray.new-fixed $a 0xff..fffor example becauseunreachableis polymorphic in its stack, but wasmparser's previous implementation would pop each individual operand from the stack (gettingMaybeType::Bottoma low), and this took time linear to the magnitude of the immediate as opposed to linear in the size of the code itself. This meant it was pretty easy to generate a small module that takes ~forever to validate, which generally is not a property we want to have.