Skip to content

Store integer registers in SavePoint #181

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

Merged
merged 1 commit into from
Feb 24, 2022

Conversation

natecook1000
Copy link
Member

Without saving the int registers, quantifications can't accurately keep track of their loop count when backtracking, so some patterns were incorrectly matching.

For example, /(a|a){3}a/ incorrectly matched against "aaaxyz", because after failing to match the final a against the "x", the engine backtracked to the second alternation without resetting the number of times the quantification had been satisfied.

Without saving the int registers, quantifications can't accurately
keep track of their loop count when backtracking, so some patterns
were incorrectly matching.

For example, /(a|a){3}a/ incorrectly matched against `"aaaxyz"`,
because after failing to match the final `a` against the `"x"`, the
engine backtracked to the second alternation without resetting the
number of times the quantification had been satisfied.
@natecook1000
Copy link
Member Author

@swift-ci Please test Linux platform

Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Another area where this bug could surface is a nested reluctant quantification, where after a restore the old int register values would still be around.

Long term, I think we want to avoid having such heavy-weight save points, but that would require switching the engine off of generalized control flow.

@natecook1000 natecook1000 merged commit 17adc2c into swiftlang:main Feb 24, 2022
@natecook1000 natecook1000 deleted the save_ints branch February 24, 2022 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants