Skip to content

Validate targets of generic lookup in the scanner - #130110

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix130028
Jul 2, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix130028

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Fixes #130028.

This way we can catch types that don't load at a spot where we can still recover (generate a throwing body). The repro already works correctly in Debug builds because we make this callout for all tokens RyuJIT resolves from IL.

Fixes dotnet#130028.

This way we can catch types that don't load at a spot where we can still recover (generate a throwing body). The repro already works correctly in Debug builds because we make this callout for all tokens RyuJIT resolves from IL.
@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.

Pull request overview

This PR tightens NativeAOT IL scanning so that invalid generic-lookup targets (types/methods that can’t be loaded) are detected during scanning, where the scanner can still recover by generating a throwing fallback body, rather than failing later in dependency analysis.

Changes:

  • Add loadability validation for TypeDesc / MethodDesc arguments passed to the scanner’s generic lookup helper path.
  • Add a NativeAOT smoke test regression that expects a TypeLoadException at runtime when invoking a method that would create an array of an oversized inline-array-based value type.

Reviewed changes

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

File Description
src/tests/nativeaot/SmokeTests/UnitTests/Generics.cs Adds a regression test (Test130028Regression) and wires it into the smoke test runner.
src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs Validates loadability of type/method lookup targets before computing helper-based generic lookups.

@MichalStrehovsky
MichalStrehovsky merged commit 414f660 into dotnet:main Jul 2, 2026
119 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the fix130028 branch July 2, 2026 21:19
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 3, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
Fixes #130028.

This way we can catch types that don't load at a spot where we can still
recover (generate a throwing body). The repro already works correctly in
Debug builds because we make this callout for all tokens RyuJIT resolves
from IL.
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 3, 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.

Crash in ilc due to a method & type being defined

3 participants