SPMI: Fix invalid format string and allow parsing full uint32 range#125874
Open
jakobbotsch wants to merge 3 commits intodotnet:mainfrom
Open
SPMI: Fix invalid format string and allow parsing full uint32 range#125874jakobbotsch wants to merge 3 commits intodotnet:mainfrom
jakobbotsch wants to merge 3 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes SuperPMI JIT host configuration parsing/logging so hex config values like DOTNET_JitHashBreak=9b29601d no longer hit an assert and can be accepted across the full uint32 range.
Changes:
- Fix
LogWarningformat specifiers to correctly print UTF-8char*strings (%sinstead of%ws). - Relax hex parsing range check from
INT_MAXtoUINT_MAXto allow values with the high bit set.
jakobbotsch
commented
Mar 20, 2026
jakobbotsch
commented
Mar 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/coreclr/tools/superpmi/superpmi/jithost.cpp:128
- Allowing values up to
UINT_MAXmeanslongResultcan be >INT_MAX, but the code then doesresult = static_cast<int>(longResult). Converting an out-of-range unsigned value tointis implementation-defined, and it’s easy to lose the intended 32-bit bit-pattern on non-two’s-complement/odd platforms. If the goal is to accept any 32-bit value (e.g. method hashes with the high bit set), consider parsing into auint32_tand then copying/bit-casting into theintresult with astatic_assert(sizeof(int) == sizeof(uint32_t)), so the bit pattern is preserved deterministically.
unsigned long longResult = strtoul(stringValue, &endPtr, 16);
bool succeeded = (errno != ERANGE) && (endPtr != stringValue) && (longResult <= UINT_MAX);
if (!succeeded)
{
LogWarning("Can't convert int config value from string, key: %s, string value: %s\n", key, stringValue);
return false;
}
result = static_cast<int>(longResult);
return true;
3 tasks
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.
Noticed that e.g.
DOTNET_JitHashBreak=9b29601dhits the error path below, which hits an assert due to%ws. Fix the format string, and then also fix the parsing so that it works properly when the upper bit is set.PTAL @dotnet/jit-contrib