Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 14, 2025

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 expected RegexMatchTimeoutException 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:

  • Reduced the timeout value from TimeSpan.FromMilliseconds(10) to TimeSpan.FromMilliseconds(1) in the Match_TestThatTimeoutHappens test method

Testing:

  • Verified the test now consistently passes across all regex engine variants (Interpreter, Compiled, NonBacktracking, SourceGenerated)
  • Confirmed related timeout tests continue to pass
  • The 1ms timeout ensures the test properly validates timeout behavior while remaining robust

Fixes #117111.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot 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
@Copilot Copilot AI requested a review from ericstj July 14, 2025 18:18
Copilot finished work on behalf of ericstj July 14, 2025 18:18
@ericstj ericstj requested a review from stephentoub July 14, 2025 18:52
@ericstj ericstj marked this pull request as ready for review July 14, 2025 18:52
@ericstj
Copy link
Member

ericstj commented Jul 15, 2025

/ba-g Android timeouts happening on multiple PRs unrelated to this test.

@ericstj ericstj merged commit f5763df into main Jul 15, 2025
83 of 87 checks passed
@jkotas jkotas deleted the copilot/fix-117111 branch July 20, 2025 00:03
@github-actions github-actions bot locked and limited conversation to collaborators Aug 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.Text.RegularExpressions.Tests.RegexMatchTests.Match_TestThatTimeoutHappens fails by not timing out
3 participants