NativeAOT: allow full-width 0x/0X-prefixed 64-bit hex env config values#128462
Open
Copilot wants to merge 2 commits into
Open
NativeAOT: allow full-width 0x/0X-prefixed 64-bit hex env config values#128462Copilot wants to merge 2 commits into
0x/0X-prefixed 64-bit hex env config values#128462Copilot wants to merge 2 commits into
Conversation
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/9942cd0a-d0b4-4b91-baba-7ff32bbc30f9 Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix NativeAOT's environment config value maximum length
NativeAOT: allow full-width May 21, 2026
0x/0X-prefixed 64-bit hex env config values
MichalStrehovsky
approved these changes
May 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates NativeAOT’s environment-variable integer config parsing to accept full-width 64-bit hex values when using the 0x/0X prefix, by increasing the fixed input buffer length and clarifying related comments.
Changes:
- Increase
CONFIG_VAL_MAXLENfrom 16 to 18 to allow"0x"+ 16 hex digits. - Update the
TryGetIntegerValuelocal buffer comment to describe a textual-length bound rather than “hex digits”.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/nativeaot/Runtime/RhConfig.h | Increases the max textual length constant for env integer config values to allow 0x/0X + 16 hex digits. |
| src/coreclr/nativeaot/Runtime/RhConfig.cpp | Updates the local buffer comment for env integer parsing to reflect the new textual max length semantics. |
Comments suppressed due to low confidence (1)
src/coreclr/nativeaot/Runtime/RhConfig.cpp:55
- This change adjusts the accepted textual length for environment-provided integer config values, but I couldn’t find any targeted test that covers a full-width prefixed value like
0xFFFFFFFFFFFFFFFF/0XFFFFFFFFFFFFFFFF(and optionally an overlong value to confirm rejection). Adding a small NativeAOT-covered test case would help prevent regressions in this parsing edge case.
TCHAR buffer[CONFIG_VAL_MAXLEN + 1]; // Max textual integer value plus a nul terminator.
const uint32_t cchBuffer = ARRAY_SIZE(buffer);
uint32_t cchResult = PalGetEnvironmentVariable(variableName, buffer, cchBuffer);
if (cchResult == 0 || cchResult >= cchBuffer)
return false;
| class RhConfig | ||
| { | ||
| #define CONFIG_VAL_MAXLEN 16 //64 bit uint in hex | ||
| #define CONFIG_VAL_MAXLEN 18 // "0x" prefix + 64-bit uint in hex |
jkotas
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #127644 made
0x/0Xvalid for non-decimal NativeAOT config parsing, butCONFIG_VAL_MAXLENstill capped input at 16 chars, rejecting full-width values like0xFFFFFFFFFFFFFFFF. This change aligns the textual length limit with the accepted syntax while preserving existing overlong-value rejection behavior.Config length limit update
CONFIG_VAL_MAXLENinsrc/coreclr/nativeaot/Runtime/RhConfig.hfrom16to18to allow0x/0X+ 16 hex digits.Comment accuracy
RhConfig.handRhConfig.cppto describe max textual integer length semantics, not just raw hex digit count.Behavioral impact
0xFFFFFFFFFFFFFFFF,0XFFFFFFFFFFFFFFFFcchResult >= cchBuffer).Original prompt
This pull request was created from Copilot chat.