fix: avoid unbounded recursion in the parser#22740
Open
Albab-Hasan wants to merge 1 commit into
Open
Conversation
deeply nested input overflows the parser stack and takes the whole process down with it (the 100k nested parens reproducer from rust-lang#9358 . track recursion depth on `Parser` and bail out with an `ERROR` node past 128 levels. each guard wraps the deepest function of its grammar family and delegates to an `_inner` fn so no return path can skip `leave_recursion`. counter instead of unwinding since unwinding past an armed `Marker` trips its `DropBomb`. the limit also bounds the syntax tree depth that everything downstream recurses over. fixes rust-lang#9824
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.
deeply nested input overflows the parser stack and takes the whole process down with it (the 100k nested parens reproducer from #9358 .
track recursion depth on
Parserand bail out with anERRORnode past 128 levels. each guard wraps the deepest function of its grammar family and delegates to an_innerfn so no return path can skipleave_recursion. counter instead of unwinding since unwinding past an armedMarkertrips itsDropBomb. the limit also bounds the syntax tree depth that everything downstream recurses over.fixes #9824