Skip to content

Fix ReadyToRun generic parameter symbol collisions - #136191

Merged
jtschuster merged 10 commits into
dotnet:mainfrom
jtschuster:fix/runtime-determined-generic-names
Nov 17, 2026
Merged

jtschuster merged 10 commits into
dotnet:mainfrom
jtschuster:fix/runtime-determined-generic-names

Conversation

@jtschuster

Copy link
Copy Markdown
Member

Fixes #135779

ReadyToRun runtime-determined type names used generic parameter metadata names. Unicode generic parameter names (e.g. List<T😊> and List<T_>) could therefore sanitize to the same symbol name, causing colliding DelayLoadHelperImport symbols.

Name synthetic runtime-determined types using the generic parameter's signature identity instead:

  • T0, T1, etc. for type parameters
  • M0, M1, etc. for method parameters

This preserves the diagnostic name behavior while keeping kind and ordinal identity distinct.

Added ReadyToRun compilation tests covering Unicode and punctuation cases in normal and composite builds.

Note

This PR description was generated with GitHub Copilot.

jtschuster and others added 2 commits October 16, 2026 13:04
Name runtime-determined types by generic parameter kind and ordinal instead of metadata display names, avoiding colliding ReadyToRun generic lookup import symbols.

Cover Unicode anonymous properties and type/method generic parameters with normal and composite Crossgen2 compilation tests.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21c1c9a0-a662-4b3d-947e-e8217da4bd10
Keep the regression test non-composite since the generic symbol collision is reproduced by the single-assembly build.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21c1c9a0-a662-4b3d-947e-e8217da4bd10
@azure-pipelines

azure-pipelines Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 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: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.

@jkotas

jkotas commented Oct 21, 2026

Copy link
Copy Markdown
Member

could therefore sanitize to the same symbol name

Would it be better to do this in the name mangler?

@MichalStrehovsky

Copy link
Copy Markdown
Member

could therefore sanitize to the same symbol name

Would it be better to do this in the name mangler?

RuntimeDeterminedType could probably become a IPrefixMangledType to enable that. We might need to change the ReadOnlySpan<byte> Prefix property to a ReadOnlySpan<byte> GetPrefix(NameMangler) method so that we can do good mangling on both the canonical type and generic parameter.

Represent runtime-determined types with IPrefixMangledType so the type's kind and generic parameter index become stable UTF-8 name prefixes.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21c1c9a0-a662-4b3d-947e-e8217da4bd10
jtschuster and others added 3 commits October 30, 2026 14:24
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21c1c9a0-a662-4b3d-947e-e8217da4bd10
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 21c1c9a0-a662-4b3d-947e-e8217da4bd10
@jtschuster
jtschuster marked this pull request as ready for review November 2, 2026 18:14
jtschuster and others added 3 commits November 16, 2026 10:46
…ition

Mangle RuntimeDeterminedType in NativeAotNameMangler as
<Owner_T#>CanonType / <Owner_M#>CanonType so generic parameters from
different owners (e.g. List<>.T and Dictionary<,>.TKey) no longer collide.
RuntimeDeterminedType no longer implements IPrefixMangledType.

Co-authored-by: Copilot <[email protected]>
@jtschuster
jtschuster merged commit 8499fe3 into dotnet:main Nov 17, 2026
99 of 101 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Nov 17, 2026
@jtschuster

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

R2R Failed when project contains anonymous types with it's property name with Non-ASCII and same length

3 participants