Repository navigation
fix(libc): print a NaN's sign in swprintf as titles' libc.prx does - #10379
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
I reviewed the NaN formatting paths and the new narrow/wide test cases. The helper preserves the negative sign and +/space precedence, and the reported same-title comparisons cover the relevant conversions and flags. Before merge, the shared-file order still needs to be recorded: pairwise merge previews with open #9916, #9927 and #9958 conflict in WindowsFormatting.hpp; #9927 and #9958 also conflict in FormattingWide.cpp. Those PRs are explicitly described here as needing to retain both sets of branches, but this PR's checklist says Depends on: none. CONTRIBUTING requires agreement on the order and the prerequisite on the checklist. Please coordinate with the authors (these are your PRs per the descriptions), declare the agreed dependency/order—e.g. stack this after #9958 if that is the intended sequence—and confirm the final result keeps both the NaN-sign branch and the existing finite/wide/long-double formatting paths. No merge is requested before that coordination.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
a8c8ce4 to
da6b45e
Compare
|
@MarcZX10 thanks. All four of those PRs are mine, so I've settled the order by stacking this PR on them. The branch is now one commit (da6b45e) on #9958's head 89f761f, so the order is #9699 → #9916 → #9927 → #9958 → this PR. The checklist now says Resolution on the stack:
Tested on the stacked head (Windows, GCC 15.2 UCRT, Release):
AI-assisted: yes (Claude Code) |
da6b45e to
6d8701a
Compare
|
Correction: after restacking I found #10223 (orezraey), opened earlier today, which already makes the narrow printf family print a NaN's sign, measured on a retail PS5. The narrow half of this PR duplicated it; I missed it in my overlap search. I've cut this PR down to the wide family only (6d8701a, still one commit on #9958): AI-assisted: yes (Claude Code) |
|
Linux run at this PR's exact head Arch Linux, kernel 7.2.9, Ryzen 9 7950X, g++ (GCC) 16.2.1 20260810, glibc 2.44, x86-64. Release,
This is the focused test only; no title, console or floating-point exception flags were checked. AI-assisted: yes (Claude Code). |
6d8701a to
afe172c
Compare
|
The refreshed order is #9699 → #9916 → #9927 → #9958 → this PR. Head |
afe172c to
8046f86
Compare
The wide printf family left NaN to the host, which dropped the sign of a negative NaN but printed +nan with the + flag. The libc.prx that titles ship prints a NaN in swprintf like an infinity, as its snprintf does: -nan for a negative NaN, +nan or " nan" with the + and space flags, NAN for the upper-case conversions, padded with spaces. The wide formatter now does the same through its own helper; the narrow family is boykopovar#10223's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8046f86 to
f8c4066
Compare
Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.
|
Checked |
What
The wide printf family (
swprintf,vswprintfand the rest) leaves NaN to the host. There, a negative NaN loses its sign, but a positive one gets+nanwith the+flag. Thelibc.prxthat titles ship formats a NaN inswprintfexactly as in itssnprintf, the way it formats an infinity:-nanfor a negative NaN;+nanwith the+flag andnanwith the space flag for a positive one;NANfor%F,%E,%Gand%A;-, and the0flag ignored.For example,
swprintf(u"[%f][%+f][% F][%5.1e]", -NAN, -NAN, NAN, -NAN)gives[-nan][-nan][ NAN][ -nan]there and[nan][+nan][ NAN][ nan]here.The wide formatter now builds that text itself for a NaN, in both the
doubleandlong doublepaths, through a smallWideNanTexthelper, and pads it with the existingAppendPadded.The narrow family's NaN sign is #10223's (orezraey, measured on a retail PS5's
libSceLibcInternal.sprx). This PR doesn't touch it. An earlier version of this PR changed it too, which duplicated #10223, so that part is gone. On #10223 I posted that eleven titles' bundledlibc.prxprint the narrow NaN text the same way.Tested
Current Linux refresh:
afe172cc68c82877b6c5f2309d70c6920a66e477on main637220db112a3daf4960984290a82fcf65ba7061. The stack is rebuilt linearly in the order #9699 → #9916 → #9927 → #9958 → #10379, with no merge commits or duplicated prerequisite commits. This PR adds one wide-NaN-sign commit. Fresh Release libc/fixture build andguest_formatting,guest_wide_formatting,guest_stdio_variadicpass (3/3) on this exact head; conventions against the tested main and whitespace checks pass. Final-stack conventions against origin/main have zero errors (six inherited debt-length warnings). All five heads also merge cleanly with newer mainc8d34aa8f4d8058d57169cc1e423ba6db00faaf0; that merge preview is not an additional runtime test. The originalWideNanTextbody and its two wide branches are retained after finite double/long-double support. Restored final-head tests pass three repeats. Reverting only this wide change also passes on Linux, so the Linux negative control does not distinguish the Windows bug. All five pinned heads, patches, checks and control logs (SHA-2569cda806ab2a54a4a0ce012517eafb7db0441ab2665d2e49884c3d1fc5b9e0c8a). No fresh Windows, title-library comparison, physical-console, game or performance result is claimed; Windows testing remains paused. The requested fresh Windows validation on #9699 is still outstanding.Historical validation on previous public head
6d8701ab2e86c426f600463dcbb9512fc6be7cbais retained below with its original scope; references there to ‘exact head’ refer to that historical run.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON, on #9958's head 89f761f.libc.prxof PPSA07923 and PPSA13934 natively and calls theirswprintf(NIDnJz16JE1txM) on NaN formats. With this PR'slibc.prxDLL, both formats print byte-identical text to both titles'swprintf.maingives[nan][+nan][ NAN][ nan]and[nan ][ nan][NAN][-inf][+NAN].guest_wide_formatting: the newCheckNanSignchecks those formats against the console's text:[-nan][-nan][ NAN][ -nan];[nan ][ -nan][-NAN][-inf][+NAN].guest_wide_formattingandguest_formattingpass in three runs out of three on the exact head.FormattingWide.cppand these tests,guest_wide_formattingaborts in aRequire, whileguest_formattingstill passes.python tools/check_conventions.py --basefix(libc): format %La like titles' libc.prx does #9958's head, andgit diff --check, pass.WindowsFormatting.hpp, so it doesn't conflict with fix(libc): format sizes, NaN signs, UTF-16 units, positions and unknown conversions as a PS5 does #10223.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)AI-assisted (Claude Code).