Skip to content

JIT: fix asserts in fgRemoveUnreachableTry - #130003

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:AndyAyersMS/fix-129971
Jun 30, 2026
Merged

AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:AndyAyersMS/fix-129971

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Ensure apparently reachable regions enclosed in an unreachable region are also correctly removed. Consistently update region ends when fgRemoveBlock removes an unreachable block.

Fixes #129970, #129971, #129972.

Ensure apparently reachable regions enclosed in an unreachable region are also correctly removed.
Consistently update region ends when fgRemoveBlock removes an unreachable block.

Fixes dotnet#129970, dotnet#129971, dotnet#129972.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 29, 2026 21:35
@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 Jun 29, 2026
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@jakobbotsch PTAL
fyi @dotnet/jit-contrib

@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.

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.

Pull request overview

This PR updates JIT EH cleanup to more robustly remove unreachable EH regions (including regions structurally enclosed within an unreachable region), and ensures EH region “last block” boundaries are kept consistent when unreachable blocks are removed—preventing verifier/assert failures in fgRemoveUnreachableTry.

Changes:

  • Update Compiler::fgRemoveUnreachableTry to track “dead” EH regions via a bitvector, propagate death through structural containment, clear stale try/handler indices, and remove EH entries from highest-to-lowest.
  • Update Compiler::fgRemoveBlock to retarget EH region end blocks when removing an unreachable block.
  • Add three JIT regression tests and wire them into the JIT regression project.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/jit/fgehopt.cpp Reworks unreachable-EH removal to also drop transitively dead (structurally enclosed) regions and to remove EH entries in a safer order.
src/coreclr/jit/fgbasic.cpp Updates EH “last block” bookkeeping when an unreachable block is removed.
src/tests/JIT/Regression/Regression_ro_2.csproj Includes the new regression tests in the build.
src/tests/JIT/Regression/JitBlue/Runtime_129970/Runtime_129970.cs Adds regression test coverage for one of the reported fgRemoveUnreachableTry assertion scenarios.
src/tests/JIT/Regression/JitBlue/Runtime_129971/Runtime_129971.cs Adds regression test coverage for the reported fgRemoveBlock assertion scenario during unreachable-try removal.
src/tests/JIT/Regression/JitBlue/Runtime_129972/Runtime_129972.cs Adds regression test coverage for the reported filter/DFS-related assertion scenario during unreachable-try removal.

@AndyAyersMS
AndyAyersMS merged commit 8b16f83 into dotnet:main Jun 30, 2026
145 checks passed
@AndyAyersMS

Copy link
Copy Markdown
Member Author

Pops, mean to run Fuzzlyn again. Will queue one up in main in a bit.

@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 30, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
Ensure apparently reachable regions enclosed in an unreachable region
are also correctly removed. Consistently update region ends when
fgRemoveBlock removes an unreachable block.

Fixes #129970, #129971, #129972.

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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: Assertion failed '!HBtab->ebdHndLast->HasFlag(BBF_REMOVED)' during 'Remove unreachable try'

3 participants