Repository navigation
fix(libc): return 64-bit values from _Stoul on Windows - #2442
Closed
SurajKhanna wants to merge 1 commit into
Closed
SurajKhanna wants to merge 1 commit into
SurajKhanna wants to merge 1 commit into
Conversation
_Stoul_nid_postfix was declared returning unsigned long and calling std::strtoul. On the PS5 (LP64), unsigned long is 64-bit, whereas on Windows (LLP64), both the return type and std::strtoul are 32-bit. On Windows builds, values exceeding UINT32_MAX were clamped to 32 bits with errno set to ERANGE (34), causing guest std::stoul to throw std::out_of_range on inputs accepted on the console. Declare _Stoul_nid_postfix returning std::uint64_t and call std::strtoull, matching strtoul_nid_postfix in Strings.cpp. Add regression tests in GuestMath.cpp. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes. |
This was referenced Oct 9, 2026
nauroth
pushed a commit
to nauroth/AnyPS5
that referenced
this pull request
Oct 9, 2026
The guest's unsigned long is 64 bits. _Stoul was declared with the host's unsigned long and returned std::strtoul, which are 32 bits on Windows (LLP64): "4294967296" clamped to 4294967295 with ERANGE and "-1" gave 0xffffffff, so a guest std::stoul threw out_of_range on values the console accepts. It now returns std::uint64_t from std::strtoull, as strtoul_nid_postfix and _Stoull already do; on Linux nothing changes. The binary-prefix check stays in front of the host call. Reported in boykopovar#2424 by AchrafReyani; the same change was proposed in boykopovar#2442 by SurajKhanna, whose two guest_math cases are taken here, with the "-1" case from boykopovar#1579 by ewraj. Folded in at MarcZX100's suggestion on boykopovar#1459. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
nauroth
pushed a commit
to nauroth/AnyPS5
that referenced
this pull request
Oct 9, 2026
The guest's unsigned long is 64 bits. _Stoul was declared with the host's unsigned long and returned std::strtoul, which are 32 bits on Windows (LLP64): "4294967296" clamped to 4294967295 with ERANGE and "-1" gave 0xffffffff, so a guest std::stoul threw out_of_range on values the console accepts. It now returns std::uint64_t from std::strtoull, as strtoul_nid_postfix and _Stoull already do; on Linux nothing changes. The binary-prefix check stays in front of the host call. Reported in boykopovar#2424 by AchrafReyani; the same change was proposed in boykopovar#2442 by SurajKhanna, whose two guest_math cases are taken here. Folded in at MarcZX100's suggestion on boykopovar#1459. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Thanks @SurajKhanna, the fix was right and the intake pause was just unlucky timing. Rather than let it sit, I've carried it into #1459, which already changes the same function: same |
SleglJan
pushed a commit
to SleglJan/AnyPS5
that referenced
this pull request
Oct 10, 2026
The guest's unsigned long is 64 bits. _Stoul was declared with the host's unsigned long and returned std::strtoul, which are 32 bits on Windows (LLP64): "4294967296" clamped to 4294967295 with ERANGE and "-1" gave 0xffffffff, so a guest std::stoul threw out_of_range on values the console accepts. It now returns std::uint64_t from std::strtoull, as strtoul_nid_postfix and _Stoull already do; on Linux nothing changes. The binary-prefix check stays in front of the host call. Reported in boykopovar#2424 by AchrafReyani; the same change was proposed in boykopovar#2442 by SurajKhanna, whose two guest_math cases are taken here. Folded in at MarcZX100's suggestion on boykopovar#1459. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
What
_Stoul_nid_postfixinRuntimeSupport.cppwas declared returningunsigned longand delegating tostd::strtoul. On the PS5 (LP64),unsigned longis 64-bit, but on Windows (LLP64),unsigned longandstd::strtoulare 32-bit. On Windows host builds, inputs exceedingUINT32_MAX(4294967295) were clamped toUINT32_MAXand seterrnotoERANGE(34), which causes gueststd::stoulcalls to throwstd::out_of_rangeon values the console accepts.Fixes this by:
_Stoul_nid_postfixreturn type tostd::uint64_tand delegating tostd::strtoull(matchingstrtoul_nid_postfixinStrings.cpp).GuestMath.cppverifying parsing of 64-bit values (4294967296and18446744073709551615) without truncation or settingERANGE.Fixes #2424.
Tested
Windows 11, GCC 16.2.0 (UCRT64):
_Stoul_nid_postfixparses 64-bit values up toUINT64_MAXwithout settingERANGE.guest_math_tests).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)