Skip to content
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

Fix PCRE2 Regex with more than 127 named capture groups #13349

Conversation

HertzDevil
Copy link
Contributor

Different things can happen when a Regex backed by PCRE2 has too many named capture groups:

  • The 256th named capture and onward will overwrite older ones in Regex#name_table;
  • The 256th named capture and onward will show up in Regex::MatchData#captures;
  • Regex::MatchData#named_captures raises OverflowError when there are 128 or more named captures.

Also fixes #13347. Note that the upper limit is 10000 in both PCRE and PCRE2.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:text labels Apr 18, 2023
@HertzDevil
Copy link
Contributor Author

It seems there is some kind of out-of-memory error in wasm32-test. Also for some reason it still uses PCRE instead of PCRE2

@straight-shoota straight-shoota added this to the 1.8.1 milestone Apr 19, 2023
@straight-shoota straight-shoota merged commit b8c514b into crystal-lang:master Apr 19, 2023
@HertzDevil HertzDevil deleted the bug/regex-capture-group-overflow branch April 20, 2023 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:text
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to build 1.8.0 when using no_number_autocast
2 participants