Fix regex timeout test by reducing timeout from 10ms to 1ms#117617
Merged
Fix regex timeout test by reducing timeout from 10ms to 1ms#117617
Conversation
Co-authored-by: ericstj <[email protected]>
Copilot
AI
changed the title
[WIP] System.Text.RegularExpressions.Tests.RegexMatchTests.Match_TestThatTimeoutHappens fails by not timing out
Fix regex timeout test by reducing timeout from 10ms to 1ms
Jul 14, 2025
ericstj
approved these changes
Jul 14, 2025
stephentoub
approved these changes
Jul 14, 2025
This was referenced Jul 15, 2025
Open
Member
|
/ba-g Android timeouts happening on multiple PRs unrelated to this test. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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_TestThatTimeoutHappenstest 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 expectedRegexMatchTimeoutExceptionfrom 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_TestThatTimeoutHappenstest 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.