Closed
Description
Description
Note that we use checked builds (which probably not used by runtime tests): <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
Reproduction Steps
using System.Text.RegularExpressions;
internal partial class Program
{
[GeneratedRegex(@"^\s*GO\s*$\n*", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled)]
private static partial Regex BuildRegex();
private static void Main(string[] args)
{
BuildRegex().Split("X\r\n XX");
}
}
Expected behavior
No exceptions
Actual behavior
System.OverflowException
HResult=0x80131516
Message=Arithmetic operation resulted in an overflow.
Source=ConsoleApp41
StackTrace:
at System.Text.RegularExpressions.Generated.<RegexGenerator_g>F74B1AE921BCEFE4BA601AA541C7A23B1CA9711EA81E8FE504B5B6446748E035A__BuildRegex_0.RunnerFactory.Runner.TryFindNextPossibleStartingPosition(ReadOnlySpan`1 inputSpan) in RegexGenerator.g.cs:line 95
at System.Text.RegularExpressions.Generated.<RegexGenerator_g>F74B1AE921BCEFE4BA601AA541C7A23B1CA9711EA81E8FE504B5B6446748E035A__BuildRegex_0.RunnerFactory.Runner.Scan(ReadOnlySpan`1 inputSpan) in RegexGenerator.g.cs:line 68
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.RunAllMatchesWithCallback[TState](String inputString, ReadOnlySpan`1 inputSpan, Int32 startat, TState& state, MatchCallback`1 callback, RegexRunnerMode mode, Boolean reuseMatchObject)
at System.Text.RegularExpressions.Regex.RunAllMatchesWithCallback[TState](String input, Int32 startat, TState& state, MatchCallback`1 callback, RegexRunnerMode mode, Boolean reuseMatchObject)
at System.Text.RegularExpressions.Regex.Split(Regex regex, String input, Int32 count, Int32 startat)
at Program.Main(String[] args) in
Regression?
No response
Known Workarounds
No response
Configuration
tfm: net7.0
extra compilation options: <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>