-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Regex Matches Count gives ArgumentOutOfRangeException (regression) #66212
Comments
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsDescriptionJust run this code with dotnet 7.0.100-preview.1.22110.4 and it will break _ = Regex.Matches("bar\n", @"(?m)^[^a]a", 0).Count Reproduction StepsClone this project: https://github.com/AlbertoMonteiro/RegexIssueDotnet7Preview1 Expected behaviorThe Count should return 1 Actual behaviorThrows Regression?On dotnet 6 it works fine Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
Thanks for the great bug report. We're missing a length check after we optimize for a beginning-of-line anchor and jump to the next \n. |
For what its worth, I was unable to verify that this fix worked, running the nightly build (found here https://github.com/dotnet/aspnetcore/blob/main/docs/DailyBuilds.md). I still see the same error. |
What version of the runtime is this using? The PR that fixed this issue added as tests the exact offending inputs: |
This is the output I get is:
Running |
What do you see for .NET 7 for |
Here's the output from that
|
Thanks. This maps to https://github.com/dotnet/runtime/commits/2330b4bef645bf8bcd3011f35968e55192c697f5 from March 2nd, which doesn't include #66216 that was merged on March 6th. I'm not sure why the current nightly installer has a two-week old runtime.... @mmitche? |
Description
Just run this code with dotnet 7.0.100-preview.1.22110.4 and it will break
Reproduction Steps
Clone this project: https://github.com/AlbertoMonteiro/RegexIssueDotnet7Preview1
Then
dotnet run
Expected behavior
The Count should return 1
Actual behavior
Throws
System.ArgumentOutOfRangeException
Regression?
On dotnet 6 it works fine
Known Workarounds
Adding an \0 to the end of the string that ends with \n doesnt throw
Returns properly 1
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: