Skip to content

Home DIM instantiating thunks on System.Object - #136128

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix136073
Oct 20, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix136073

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Fixes #136073

These need to be homed on something that is not generic so we cannot place them on the interface itself: it causes issues around whether these require instantiating argument (they don't) that requires lots of special casing to back out.

This is probably the cleanest local fix. It doesn't work for the multi-obj file mode (these now all look like they should be compiled into CoreLib.obj). We can live with that, considering everything else.

Fixes dotnet#136073

These need to be homed on something that is not generic so we cannot place them on the interface itself: it causes issues around whether these require instantiating argument (they don't) that requires lots of special casing to back out.

This is probably the cleanest local fix. It doesn't work for the multi-obj file mode (these now all look like they should be compiled into CoreLib.obj). We can live with that, considering everything else.
@azure-pipelines

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

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
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.

🔵 Needs a closer look

NativeAOT execution remains unverified, and the acknowledged multi-object compilation limitation requires maintainer acceptance.

No open issues 🎉

What changed in this PR

Addresses NativeAOT issue #136073 by moving default interface method instantiating thunks onto the non-generic System.Object type.

Changes:

  • Removes explicit thunk-owner storage and construction arguments.
  • Adds regression coverage for shared generic default implementations using object and string.
File Description
src/​tests/​Loader/​classloader/​DefaultInterfaceMethods/​regressions/​github136073.csproj Includes the regression test source.
src/​tests/​Loader/​classloader/​DefaultInterfaceMethods/​regressions/​github136073.cs Tests receiver casting and generic type identity.
src/​coreclr/​tools/​aot/​ILCompiler.Compiler/​Compiler/​CompilerTypeSystemContext.InterfaceThunks.cs Homes instantiating thunks on System.Object.

Review effort: Balanced

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/ba-g the native AOT failure is known

@MichalStrehovsky
MichalStrehovsky merged commit a4a2c91 into dotnet:main Oct 20, 2026
140 of 144 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the fix136073 branch October 20, 2026 12:45
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 21, 2026
agocke pushed a commit that referenced this pull request Nov 11, 2026
Backport of #136128 to release/11.0

/cc @MichalStrehovsky

## Customer Impact

- [X] Customer reported
- [ ] Found internally

#136073 - default interface method instantiating thunks need to be homed
on a different type but they're conceptually instance methods on the
interface. Inlining into these thunks can produce bad optimizations. In
this case, RyuJIT optimized out "impossible" code path that is actually
possible.

## Regression

- [X] Yes
- [ ] No

We have always reported these on the "wrong" type, this was triggered by
more inlining.

## Testing

Added targeted regression test. This requires interaction of at least
two optimizations (first we need to inline, and then make a decision
about `this`).

## Risk

The risk should be low, the fix was straightforward and didn't require
any adjustments with our existing DIM testing.

**IMPORTANT**: If this backport is for a servicing release, please
verify that:

- For .NET 8 and .NET 9: The PR target branch is `release/X.0-staging`,
not `release/X.0`.
- For .NET 10+: The PR target branch is `release/X.0` (no `-staging`
suffix).

## Package authoring no longer needed in .NET 9

**IMPORTANT**: Starting with .NET 9, you no longer need to edit a NuGet
package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older
versions.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NativeAOT (.NET 11 RC2, osx-arm64): SIGTRAP in the instantiating stub of a default interface IFormattable.ToString on a shared-generic interface

3 participants