fix(libc): format sizes, NaN signs, UTF-16 units, positions and unknown conversions as a PS5 does #10223
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10223"
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 orezraey on 2026-10-23T14:29:45Z.
What
The narrow printf family measured on a retail PS5 (firmware 13.60) through
libSceLibcInternal.sprx'ssnprintffrom a payload process, on the points the debt file listed as unverified. The sources and console logs are in this gist (pfmt5topfmt7). I ran the same cases through AnyPS5 on Windows and fixed the five that differed:snprintfwith a size aboveINT_MAX + 1, up toSIZE_MAXEOVERFLOW, following FreeBSD%f,%e,%g,%a;%+f,% fof a NaN-nan,+nan,nan;%Fgives-NANnanalways%08fof a NaN-nan)%lswith a surrogate pair (U+1F600)ED A0 BD ED B8 80F0 9F 98 80%100$dand above (400 measured)%m,%k,%y,%5k,%-3y,%lk,%#k,%.2k,%0$d)%and its letter, padded to the width,#and precision ignored, no argument taken ([ %k],[%y ],[%k],%$d)%mprintedstrerror(errno); after #3987,#and precision threwLone surrogates,
%.2lscutting a whole character, and the zero flag padding infinities with spaces already matched.On Linux, formats with an unknown conversion now go to the guest formatter, as
%mdid; glibc already prints NaN the console's way. The_sforms still throw for an unknown conversion,%mincluded, since they were not measured. Positions above 65535 throw. The debt entries are rewritten.These are
libSceLibcInternal.sprx's results; a title that ships its ownlibc.prxmay differ. #9699, #9916 and #9927 edit the NaN lines ofWindowsFormatting.hpp; whichever lands second keeps both changes. #3987 landed first andmainis merged: its%q,%D/%O/%U, width,-,%5%and trailing-%behaviour is kept, and its unknown-conversion branch is folded into this PR's. Only the measured cases change:#, precision and a0without a width are ignored (%#kand%.2kprint%kinpfmt7), so%#yand%.2ynow print%y;+, space,'and0with a width on an unknown conversion are unmeasured and still throw, as do the_sforms. On Linux a format with an unknown conversion goes to the same formatter, and the size given to glibc is capped atINT_MAX + 1, since glibc fails aSIZE_MAXsize where the console formats.Tested
Windows 11, MinGW (winlibs).
guest_formattingchecks every row above, the counts, and positions 99 and 100. It fails onmainand passes three runs in a row with the change, as do the 15 other formatting, scanning, wide, strftime and syslog tests.4756ead:cmake --build . --target guest_formatting_tests, thenctest -R "^guest_formatting$" --output-on-failurepasses three runs in a row. Its%m,%k,%y,%lkand%0$dchecks are not Windows-only, so they cover the newRequiresGuestFormattingrouting.1393a91fdf(main merged after #3987):guest_formatting,guest_wide_formattingandguest_safe_errorspass three runs in a row on Windows 11 (WinLibs GCC 15.2) and on Linux (WSL2 Arch, GCC 16.2). Before the size cap,guest_formattingfailed on Linux at theSIZE_MAXsnprintfcheck, 3 of 3.30f054270f(the unmeasured unknown-conversion cases%0y,%+y,% y,%'yand%05ydropped from the tests; production still throws for+, space,'and a zero flag with a width):guest_formatting,guest_wide_formattingandguest_safe_errorspass three runs in a row on Windows 11 (WinLibs GCC 15.2) and on Linux (WSL2 Arch, GCC 16.2).tools/check_conventions.pypasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T14:37:51Z.
Review: CHANGES_REQUESTED
The Windows measurements and focused formatting coverage are useful, and the hosted conventions/relinker/register-context checks pass. Two items still need closing before this is ready for approval:
RequiresGuestFormattingrouting for unknown conversions), and report the command/result. The PR description currently says Linux was not run, and hosted Linux/Windows product jobs are skipped.WindowsFormatting.hpp's conversion branch alongside #3987, and the overlap report also lists several in-flight libc math PRs that edit the debt file. The repository checklist asks authors to agree on ordering for overlapping changes. Please coordinate with #3987's author and record the agreed order inDepends on(or confirm the changes are independent after the shared-line review), while preserving both implementations.I have not approved this head because the Linux-only behavior has no reported test yet.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T20:22:35Z.
Review: APPROVED
Reviewed head
4756ead5d75f17ef19ff004e6f9bb2ccb5c7d18a. I checked the formatter and Linux dispatch changes, including size handling, NaN sign/flags, UTF-16-unit encoding, numbered arguments, unknown-conversion formatting, and the corresponding tests/debt note. The author has since reported the focused Linuxguest_formattingtarget passing three times at this exact head, and the PR now records its ordering dependency on #3987. The current hosted conventions, relinker, register-context, and write-watch checks pass; hosted full Linux and Windows product jobs are skipped. I could not start the documented manual full build because GitHub returned HTTP 403 (repository admin rights required). I did not independently rerun the Linux formatter test in this workspace. No blocking issue found in the reviewed diff. AI-assisted review.