Skip to content

[5.7] Fix infinite loop and scalar matching in grapheme mode + scalar matching optimizations #569

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

Conversation

rctcwyvrn
Copy link
Contributor

@rctcwyvrn rctcwyvrn commented Jul 12, 2022

Cherry pick of #525 (which includes #565) and #560

rdar://97394951

@hamishknight
Copy link
Contributor

  • Explanation: Fixes UnicodeScalar matching behavior in the DSL, such that we do not consume part of a grapheme. Additionally fixes the matching engine such that we avoid creating an infinite loop when attempting to match a quantification of a potentially empty match.

  • Scope: Affects the runtime matching behavior of regex literals and DSLs.

  • Radar: rdar://97394951

  • Risk: Low/Medium – This does require making quite a few changes to the machine engine logic, however many test cases have been added to ensure correctness.

  • Testing: Added test cases to the repo.

  • Reviewer: @milseman

@hamishknight hamishknight added the r5.7 5.7 Release Cherry Picks label Jul 21, 2022
…ftlang#560)

This fixes infinite loops when we loop over an internal node that does not have any forward progress. Also included is an optimization to only emit the check/break instructions if we have a case that might result in an infinite loop (possibly non-progressing inner node + unlimited quantification)
)

- Adds new instructions for matching characters and scalars case insensitively
- Compiles ascii character matches into the faster scalar match instructions even in grapheme semantic mode
- Optimizes out unnecessary runtime grapheme boundary checks for all ascii strings
- Also includes fixes to scalar matching in grapheme semantic mode (swiftlang#565)
@hamishknight hamishknight force-pushed the uhoh-infinite-loop-5.7 branch from 3235ef3 to 5f5848e Compare July 21, 2022 22:22
@hamishknight
Copy link
Contributor

@swift-ci please test

@hamishknight hamishknight merged commit 7aedd69 into swiftlang:swift/release/5.7 Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r5.7 5.7 Release Cherry Picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants