Skip to content

JIT: reject filters starting at the end of the method - #138662

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:jit-filter-offset
Open

AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:jit-filter-offset

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

A filter offset equal to the IL code size passes validation, but its
basic-block lookup returns null and the JIT dereferences it. Reject the
offset and check the lookup result before using it.

Add an IL regression test that expects InvalidProgramException.

Validation

  • .\build.cmd clr+libs+host -rc checked: passed.
  • src\tests\build.cmd -Test JIT/Directed/Directed_d.csproj x64 Checked -Priority 1: passed.
  • Ran filteroffset.dll with the matching Windows x64 Checked Core_Root:
    the unfixed JIT terminated with access violation 0xC0000005; the
    fixed JIT returned the expected exit code 100.
  • The full test suite was not run.

Note

This PR description was generated with GitHub Copilot.

A filter offset equal to the IL code size passes validation, but the
block lookup returns null and the JIT dereferences it. Reject the offset
and check the lookup result before using it.

Add an IL regression test that expects InvalidProgramException.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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 Dec 3, 2026
@azure-pipelines

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

@AndyAyersMS
AndyAyersMS requested review from adamperlin and a balanced review from Copilot December 3, 2026 00:18
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@adamperlin ptal
fyi @dotnet/jit-contrib

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.

🟢 Approval recommended

There are no active review issues for the JIT filter-offset validation change.

No open issues 🎉

What changed in this PR

Prevents a JIT null dereference when malformed IL places an exception filter at the end of a method.

Changes:

  • Reject filter offsets equal to the IL code size and guard against null basic-block lookups.
  • Add a priority-1 IL regression test expecting InvalidProgramException.
File Description
src/​tests/​JIT/​Directed/​Directed_d.csproj Registers the regression test.
src/​tests/​JIT/​Directed/​coverage/​importer/​filteroffset.ilproj Defines the priority-1 IL test project.
src/​tests/​JIT/​Directed/​coverage/​importer/​filteroffset.il Tests rejection of an end-of-method filter offset.
src/​coreclr/​jit/​fgbasic.cpp Tightens filter validation and guards the lookup result.

Review effort: Balanced

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

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.

3 participants