Fix regex timeout test by reducing timeout from 10ms to 1ms #117617
Merged
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.
The
System.Text.RegularExpressions.Tests.RegexMatchTests.Match_TestThatTimeoutHappens
test was intermittently failing because the compiled regex engine has become fast enough to complete the catastrophic backtracking operation within the current 10ms timeout, preventing the expectedRegexMatchTimeoutException
from being thrown.The test uses the regex pattern
a.{20}^
against a large input string (1 million characters) which should cause catastrophic backtracking and trigger a timeout. However, with recent optimizations to the compiled regex engine, this operation sometimes completes within 10ms.Changes:
TimeSpan.FromMilliseconds(10)
toTimeSpan.FromMilliseconds(1)
in theMatch_TestThatTimeoutHappens
test methodTesting:
Fixes #117111.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.