You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IndexOutOfRangeException when using compiled and ignorecase regex in .NET 7.0 #79298
Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Regex1_TryMatchAtCurrentPosition(RegexRunner, ReadOnlySpan`1)
at Regex1_Scan(RegexRunner, ReadOnlySpan`1)
at System.Text.RegularExpressions.Regex.ScanInternal(RegexRunnerMode mode, Boolean reuseMatchObject, String input, Int32 beginning, RegexRunner runner, ReadOnlySpan`1 span, Boolean returnNullIfReuseMatchObject)
at System.Text.RegularExpressions.Regex.RunSingleMatch(RegexRunnerMode mode, Int32 prevlen, String input, Int32 beginning, Int32 length, Int32 startat)
at System.Text.RegularExpressions.Regex.IsMatch(String input)
at Program.Main()
Reproduction Steps
varregex=newRegex(@"(ver\.? |[_ ]+)?\d+(\.\d+){2,3}$",RegexOptions.Compiled|RegexOptions.IgnoreCase);Console.WriteLine(regex.IsMatch(" Ver 2.0"));// Throws (you can add anything before Ver, but something must exists).
Expected behavior
No throw.
Actual behavior
Throws.
Regression?
Yes, works in .NET 6.0 and .NET Framework.
Known Workarounds
No response
Configuration
.NET 7.0.
Windows 10 22H2
x64
Happens on Linux too.
Activity
stephentoub commentedon Dec 7, 2022
Thanks for the helpful repro. I've put up a fix in #79353.
Nuklon commentedon Dec 8, 2022
Thanks for the fix @stephentoub and also for the backport as this prevents me from upgrading.
stephentoub commentedon Dec 8, 2022
You're welcome. Would you be able to try it out and validate your issue is entirely addressed?
Nuklon commentedon Dec 10, 2022
I can give it a try if it's in the daily build, I'm not sure it is yet?
buyaa-n commentedon Dec 21, 2022
It should have included in daily build already