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 negative lookaround stack handling #99424

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2712,6 +2712,12 @@ void EmitNegativeLookaroundAssertion(RegexNode node)
// If the generated code ends up here, it matched the lookaround, which actually
// means failure for a _negative_ lookaround, so we need to jump to the original done.
writer.WriteLine();
if (hasCaptures && isInLoop)
{
// Pop the crawl position from the stack.
writer.WriteLine("stackpos--;");
EmitStackCookieValidate(stackCookie);
}
Goto(originalDoneLabel);
writer.WriteLine();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,15 @@ void EmitNegativeLookaroundAssertion(RegexNode node)
// If the generated code ends up here, it matched the lookaround, which actually
// means failure for a _negative_ lookaround, so we need to jump to the original done.
// goto originalDoneLabel;
if (capturePos is not null && isInLoop)
{
// Pop the crawl position from the stack.
// stackpos--;
Ldloc(stackpos);
Ldc(1);
Sub();
Stloc(stackpos);
}
BrFar(originalDoneLabel);

// Failures (success for a negative lookaround) jump here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,6 @@ public static IEnumerable<object[]> RecreationalRegex_Rectangle_MemberData()
}
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/98962")]
[Theory]
[MemberData(nameof(RecreationalRegex_Rectangle_MemberData))]
[OuterLoop("May take several seconds")]
Expand Down