-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add check for regex instructions causing an infinite-loop #10095
Add check for regex instructions causing an infinite-loop #10095
Conversation
Codecov Report
@@ Coverage Diff @@
## branch-22.04 #10095 +/- ##
=============================================
Coverage 10.37% 10.38%
=============================================
Files 119 119
Lines 20149 20220 +71
=============================================
+ Hits 2091 2099 +8
- Misses 18058 18121 +63
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple questions (only one really important one) otherwise this looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@gpucibot merge |
Closes #10006
Fixes a use case where the regex pattern creates a set of instructions that can cause the regex evaluation process to go into an infinite loop. For example, the pattern
(x?)+
creates the following instructions:This causes in an infinite loop at instruction 4 where the path may go like: 4->3->1->2->4 ... forever.
Supporting this pattern does not look possible. The
+
quantifier is applied to capture group symbol)
inside of whichx?
means 0 or more repeating the characterx
. This means it could matchx
or nothing and so applying the+
to nothing would be invalid. That said, the patternx?+
currently already throws an error because of the invalid usage of+
quantifier.Therefore, the fix here adds a checking step after the instruction set is created to check for a possible infinite-loop case. If one is detected, an exception is thrown indicating the pattern is not supported.