Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 19, 2025

Backport of #118870 to release/10.0-rc1

/cc @AndyAyersMS

Customer Impact

  • Customer reported
  • Found internally

Reported by @thoenissen in #118837.

Regression

  • Yes
  • No

In .NET 10 the JIT can now inline some methods with EH. When a C++/CLI method with a fault or filter clause is inlined into a dynamic method, it exposes a pre-existing issue where the runtime will try and interpret the classToken field of the finally/filter EH clause as a class handle, despite the fact that this field has no meaning for those kinds of clauses. C++/CLI leaves garbage values these fields and the JIT simply passes that field along to the runtime, leading to unexpected InvalidProgramExceptions from the runtime.

Testing

Tested the fix using the example from the customer.

Risk

Low. The JIT now zeros the classToken field for finally/fault clauses, and the runtime no longer looks at the field values.

C++/CLI appears to leave the CORINFO_EH_CLAUSE ClassToken/FilterOffset union
set to some nonzero value for fault/filter clauses. The JIT currently just
passes this value along to the runtime.

If a method with such a nonzero field is inlined into a dynamic method, this
trips up a check in the runtime where a nonzero entry for such a field is
interpreted as a class handle, even for fault/filter clauses where it should
be ignored.

Tolerate this by zeroing the field in the JIT.

Note this could not have happened in pre .NET10 as methods
with EH could not be inlined, so a dynamic method would never see such
an EH clause, and in non-dynamic methods this field is ignored for
faults and filters.

Fixes #118837.
@AndyAyersMS
Copy link
Member

@dotnet/jit-contrib PTAL
fyi @JulieLeeMSFT @jeffschwMSFT

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

lgtm. please get a code review. we will take for consideration in 10 rc1

@jeffschwMSFT jeffschwMSFT added Servicing-consider Issue for next servicing release review area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Aug 19, 2025
@jeffschwMSFT jeffschwMSFT added this to the 10.0.0 milestone Aug 19, 2025
Copy link
Contributor

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

@artl93 artl93 added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Aug 20, 2025
@ViktorHofer
Copy link
Member

ViktorHofer commented Aug 21, 2025

If this PR should still go into RC1, please merge it asap. cc @jeffschwMSFT

@jeffschwMSFT jeffschwMSFT merged commit 13f9524 into release/10.0-rc1 Aug 21, 2025
107 of 113 checks passed
@jkotas jkotas deleted the backport/pr-118870-to-release/10.0-rc1 branch August 28, 2025 21:05
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 Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants