Skip to content

More timeout checks in RegexOptions.NonBacktracking #74531

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

Closed

Conversation

olsaarik
Copy link
Contributor

This PR adds timeout checking into matching loops in all phases of RegexOptions.NonBacktracking, while previously only the first "find the end position" phase had the check. The second "find the start position by walking backwards" phase uses the same number of innermost loop iterations between cheks as the first one. However, the third phase for finding subcaptures uses a lower one to account for the phase being slower in general. I measured that the 100 characters per timeout check gives around a 15ms resolution in the third phase.

The constants configuring those numbers of iterations are moved into SymbolicRegexThresholds.

This PR includes the bug fix from #74525 to avoid a conflict after that one is merged.

@ghost
Copy link

ghost commented Aug 24, 2022

Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR adds timeout checking into matching loops in all phases of RegexOptions.NonBacktracking, while previously only the first "find the end position" phase had the check. The second "find the start position by walking backwards" phase uses the same number of innermost loop iterations between cheks as the first one. However, the third phase for finding subcaptures uses a lower one to account for the phase being slower in general. I measured that the 100 characters per timeout check gives around a 15ms resolution in the third phase.

The constants configuring those numbers of iterations are moved into SymbolicRegexThresholds.

This PR includes the bug fix from #74525 to avoid a conflict after that one is merged.

Author: olsaarik
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: -

@olsaarik olsaarik force-pushed the nonbacktracking-timeout-all-phases branch from 5056870 to 45671cd Compare September 8, 2022 22:06
@stephentoub
Copy link
Member

@joperezr, are we trying to get this into 7?

@olsaarik, can this be rebased now that #74525 was merged?

@joperezr
Copy link
Member

Hey @olsaarik sorry for missing this. Is this ready for review?

@joperezr
Copy link
Member

joperezr commented Nov 2, 2022

friendly ping @olsaarik 😄 Are you waiting on a review for this?

@olsaarik
Copy link
Contributor Author

olsaarik commented Nov 8, 2022

Thanks for the ping. If I remember correctly I mostly finished this, but I'll give it a look and make sure all the tests pass. I'll let you know when it's ready for review

@ericstj
Copy link
Member

ericstj commented Dec 5, 2022

@olsaarik, could you let us know if you had a chance to look at this? Thanks!

@buyaa-n
Copy link
Contributor

buyaa-n commented Jan 4, 2023

@olsaarik, if the PR is not ready yet, should we convert it to draft?

@olsaarik olsaarik marked this pull request as draft January 17, 2023 23:51
@olsaarik
Copy link
Contributor Author

This had dropped off my radar. Returned to draft now and I'll get back to it.

@ghost ghost closed this Feb 17, 2023
@ghost
Copy link

ghost commented Feb 17, 2023

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@stephentoub stephentoub reopened this Feb 21, 2023
@ghost ghost closed this Mar 23, 2023
@ghost
Copy link

ghost commented Mar 23, 2023

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 22, 2023
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants