Skip to content

Fix JIT filter successors for finally blocks in sibling catch handlers - #134505

Open
jakobbotsch with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-jit-bug-assert-phi-found
Open

jakobbotsch with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-jit-bug-assert-phi-found

Conversation

Copilot AI commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

The JIT incorrectly models an EH edge from a filter to a finally nested inside a mutually-protecting sibling catch. This disagrees with predecessor enumeration and triggers an SSA phi-insertion assertion.

  • Traversal: Follow only enclosing-try links, matching BlockPredsWithEH. Continue past non-enclosed descriptors so earlier valid finally/fault successors remain discoverable.
  • Regression coverage: Exercise the sibling-catch case and preserve valid filter-to-finally flow through a nested handler inside the outer try.

@azure-pipelines

azure-pipelines Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 23, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Comment on lines +12 to +25
[Theory]
[InlineData(5, false, 6)]
[InlineData(0, false, 1)]
[InlineData(5, true, 0)]
public static void TestEntryPoint(int arg, bool argumentException, int expected)
{
s_sink = -1;
Assert.Equal(expected, Test(arg, argumentException));
Assert.Equal(expected, s_sink);

s_sink = -1;
Assert.Equal(expected, TestWithEnclosedFinally(arg, argumentException));
Assert.Equal(expected, s_sink);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot We do not need multiple InlineData here, a single Fact with a single testing value suffices.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in bef02dc to a single [Fact] using input 5 and expected result 6. Both EH shapes remain covered. The focused test passed on the Checked JIT.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Either remove the argumentException parameter and simplify the test further, or call it from TestEntryPoint with true now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added argumentException: true calls for both helpers in TestEntryPoint, with return-value and sink assertions, in 188c7c5. The single Fact passes on the Checked JIT.

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
@jakobbotsch

Copy link
Copy Markdown
Member

cc @dotnet/jit-contrib PTAL @AndyAyersMS

No diffs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

EH control-flow changes require final human review.

Review effort: Lite
Findings: None

What changed in this PR

Fixes JIT EH successor modeling for filters and sibling catch handlers, with regression coverage.

Changes:

  • Restricts traversal to enclosing try links.
  • Adds sibling-catch and nested-finally regression tests.
File Description
src/​tests/​JIT/​Regression_ro_2/​Runtime_134457.cs Adds regression tests for issue #134457.
src/​coreclr/​jit/​compiler.hpp Corrects EH successor traversal.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: (bug) assert phiFound || ... in SSA for a filter whose mutually-protecting sibling catch contains a try/finally

4 participants