Skip to content

Fix NativeAOT dependent handle secondary access with standalone GC#128118

Merged
jkotas merged 1 commit into
dotnet:mainfrom
jbevain:nativeaot-standalone-gc-dependent-handles
May 13, 2026
Merged

Fix NativeAOT dependent handle secondary access with standalone GC#128118
jkotas merged 1 commit into
dotnet:mainfrom
jbevain:nativeaot-standalone-gc-dependent-handles

Conversation

@jbevain
Copy link
Copy Markdown
Contributor

@jbevain jbevain commented May 13, 2026

Summary

Fix NativeAOT dependent handle secondary get/set helpers to go through IGCHandleManager instead of the CoreCLR handle-table helper functions directly.

RhpHandleAllocDependent already creates dependent handles through the active IGCHandleManager, which is required for standalone GC support. However, RhHandleGetDependent and
RhHandleSetDependentSecondary accessed the secondary object through the CoreCLR global helpers:

GetDependentHandleSecondary(handle)
SetDependentHandleSecondary(handle, secondary)

That assumes the handle is a CoreCLR handle-table handle. With standalone GC enabled, the handle belongs to the standalone GC handle manager, so secondary-object access must use the
same handle-manager abstraction as allocation, free, primary store, and extra-info access.

Details

This changes:

RhHandleGetDependent
RhHandleSetDependentSecondary

to call:

GCHandleUtilities::GetGCHandleManager()->GetDependentHandleSecondary(handle)
GCHandleUtilities::GetGCHandleManager()->SetDependentHandleSecondary(handle, secondary)

For the built-in GC handle manager this preserves existing behavior, since the manager implementation forwards to the same CoreCLR helpers internally. For standalone GC
implementations, it lets the active handle manager interpret its own dependent-handle representation.

@jbevain jbevain requested a review from MichalStrehovsky as a code owner May 13, 2026 05:01
Copilot AI review requested due to automatic review settings May 13, 2026 05:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 13, 2026
@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.

Copy link
Copy Markdown
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks!

@jkotas jkotas merged commit 1843a48 into dotnet:main May 13, 2026
122 checks passed
@jbevain jbevain deleted the nativeaot-standalone-gc-dependent-handles branch May 13, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants