_Stoul truncates to 32 bits on Windows (unsigned long is 32-bit there) #2424
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T19:19:48Z.
_Stoul_nid_postfix(core/libs/prx/libc/src/RuntimeSupport.cpp) is declared to returnunsigned longand callsstd::strtoul. On the PS5 (LP64),unsigned longis 64-bit. On Windows (LLP64), both the return type andstrtoulare 32-bit. So on the Windows build, the guest's_Stoul(the Dinkumware helper behindstd::stoul) clamps every value aboveUINT32_MAXand setsERANGE. A gueststd::stoulwould then throwout_of_rangeon inputs the console accepts.Probe calling the export directly, on current
main(Windows 11, WinLibs GCC 15.2.0 r7):_Stoul_Stoull(correct)42949672954294967296500000000018446744073709551615-1On Linux,
unsigned longis 64-bit, so the same code is correct there.A fix is a one-liner: return
std::uint64_t(orunsigned long long) and callstd::strtoull, likestrtoul_nid_postfixinStrings.cppalready does. A grep of the exports found no other function with a plainlongin its signature.I haven't opened a PR because #1459 changes the body of this function and #2170 touches the lines next to it, and intake is paused for my account. Whichever lands first could include it.
AI-assisted: yes (the probe was written and run with Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T20:57:26Z.
Update after checking the live PR queue: #2442 was automatically closed by the repository’s intake-pause workflow shortly after opening; its Conventions check passed, and the closure comment says this was not a quality judgment. Open PR #1459 also edits
_Stoul_nid_postfixwhile fixing Linux C17 binary-prefix parsing. I left a coordination note there asking whether the compatible Windows 64-bit conversion should be folded into that existing branch or kept as a future follow-up. No duplicate patch or PR has been created.Imported from boykopovar/AnyPS5. Originally posted by nauroth on 2026-10-09T21:41:52Z.
Thanks @AchrafReyani for the clear report and the probe values. Since #1459 already touches
_Stoul_nid_postfix, and @MarcZX100 suggested folding it in rather than waiting for intake to resume, the 64-bit fix is now a separate commit on that branch:std::uint64_tfromstd::strtoull, withguest_mathchecking"4294967296","18446744073709551615"and"-1". The cases come from @SurajKhanna's #2442, credited in the commit message. If #1459 lands, this can close with it.Imported from boykopovar/AnyPS5. Originally posted by mrlempticles on 2026-10-10T00:06:18Z.
I've implemented a fix for this in my fork (branch ix/libc-stoul-windows-truncation). Changed _Stoul_nid_postfix to return unsigned long long and use std::strtoull to match PS5 LP64 behavior. Will resubmit a PR when intake reopens.
Imported from boykopovar/AnyPS5. Originally posted by Yuva1024 on 2026-10-10T02:11:19Z.
The 64-bit fix is on
mainas2243e17f, merged with #1459:_Stoul_nid_postfixreturnsstd::uint64_tfromstd::strtoull. I think this can be closed.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T03:08:05Z.
Fixed by #1459 (
2243e17f):_Stoulnow returns a 64-bit value fromstrtoullon Windows too. Reopen if it still truncates on current main.