Uh oh!
There was an error while loading. Please reload this page.
Fix NativeAOT string GC config handling - #128455
Conversation
The NativeAOT doesn't have real implementation of GCToEEInterface::GetStringConfigValue, the method just return false. That prevents extraction of settings that are strings, like GCHeapAffinitizeRanges. This change fixes it by adding proper implementation. Closedotnet#128396
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
This PR updates the NativeAOT runtime’s GC configuration plumbing so that string-valued GC configs can be retrieved (instead of always being treated as absent), bringing NativeAOT behavior closer to CoreCLR for settings like heap affinitization ranges.
Changes:
- Add NativeAOT
RhConfighelpers to read string config values fromDOTNET_*environment variables and from embedded config blobs. - Implement
GCToEEInterface::GetStringConfigValuefor NativeAOT by delegating to the newRhConfigstring readers. - Route
GCToEEInterface::FreeStringConfigValuethroughRhConfigfor consistent ownership handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/coreclr/nativeaot/Runtime/RhConfig.h | Adds declarations for reading and freeing string config values (settings + knobs). |
| src/coreclr/nativeaot/Runtime/RhConfig.cpp | Implements string config retrieval (env + embedded) and centralized freeing. |
| src/coreclr/nativeaot/Runtime/gcenv.ee.cpp | Wires GC string config lookup/freeing to RhConfig for NativeAOT. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
MichalStrehovsky
commented
May 25, 2026
Could we update the GetConfigurationVariables.cs test to test this? The test is not really testing anything right now: mark the test as RequiresProcessIsolation, add CLRTestEnvironmentVariable setting this, and verify we can see it in GetConfigurationVariables. |
MichalStrehovsky
left a comment
There was a problem hiding this comment.
Looks like the test needs TestLibrary.PlatformDetection.IsMonoRuntime conditioning, but LGTM otherwise, thanks!
janvorli
commented
Jun 2, 2026
/backport to release/10.0 |
Started backporting to |
Backport of #128455 to release/10.0 /cc @janvorli ## Customer Impact - [x] Customer reported - issue #128396 - [ ] Found internally When publishing with NativeAOT (PublishAot=true), the GCHeapAffinitizeRanges configuration is ignored regardless of how it is supplied — RuntimeHostConfigurationOption in the .csproj, IlcArg --runtimeopt:, or the DOTNET_GCHeapAffinitizeRanges environment variable. The Server GC heap threads fall back to the default per-heap affinity (heap 0 → CPU 0, heap 1 → CPU 1, etc.) instead of the user-specified ranges. The same configuration works correctly in non-AOT builds. ## Regression - [ ] Yes - [x] No ## Testing Local testing using targeted repro app provided by the customer, local NativeAOT tests execution, CI. ## Risk Low, the change is specific to string config values handling in NativeAOT that was ignoring those before. --------- Co-authored-by: Jan Vorlicek <janvorli@microsoft.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
The NativeAOT doesn't have real implementation of
GCToEEInterface::GetStringConfigValue, the method
just return false. That prevents extraction of
settings that are strings, like GCHeapAffinitizeRanges.
This change fixes it by adding proper implementation.
Close#128396