libc: the wide printf family aborts on %qd, %D, %O, %U, unknown conversions and a trailing % that FreeBSD formats; fix branch ready #5293
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 husseinkad on 2026-10-13T16:38:25Z.
The wide printf family (
swprintf,vswprintf, andsnwprintf_sfor the plain formats) aborts the guest on four things FreeBSD 11.4vfwprintf.cformats: theqlength modifier (%qd), the%D,%Oand%Uconversions, an unknown conversion character (%y,%5%), and a format ending in a lone%(swprintf(.., L"100%")returns -1 where FreeBSD stops and returns 3). This is the wide counterpart of #3975, whose fix covers only the narrowFormatWindowspath.Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/libc-wide-printf-extensions (two commits on a recent main: the change and a follow-up from review;
libc/src/FormattingWide.cpp,tests/GuestWideFormatting.cppwith a newCheckFreebsdConversions, and onedocs/dev/debt/libc.mdline).qmeans long long,D/O/Uare the long forms, an unknown character prints itself with width and the-flag (a surrogate pair prints whole and counts as one character), and a trailing%ends the format.%m,%',$,%l5d,%lqd,%qqd,%lp,%qpand%hqstill throw as before, andsnwprintf_skeeps rejecting all of these.Checks:
guest_wide_formatting,guest_formatting,guest_standard_streamandfile_streamspass.vfwprintf/vswprintf(with its gdtoa), including surrogate pairs and lone surrogates: 0 regressions (no format that matched FreeBSD on main stops matching);snwprintf_sis identical to main on 700k formats; none of the 10k random formats that worked on main changed output or return value;%D,%O,%Uwithh,hh,l,ll,jandzand the100%,a%-and%%%cases match.snwprintf_shad started acceptingqand that a surrogate pair used as an unknown conversion character was split into invalid UTF-16; both are fixed in the second commit.check_conventions.pyis clean andpr_overlap.pyfinds no overlap.Not fixed here:
%#.0Oof 0 prints nothing where FreeBSD prints0(the existing%#.0obug, whichOinherits);%0%and%010%pad with blanks where FreeBSD zero-pads (listed in the debt entry together with the other unknown-conversion padding), as do%05lsand%05lc;%LDand%Ld, stacked modifiers such as%hz, and flags after the width are rejected; truncation returns -1 without settingEOVERFLOW. Only Windows was built and run.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T16:46:33Z.
Carried the fix into PR #5303: https://github.com/boykopovar/AnyPS5/pull/5303. Linux
guest_wide_formattingandguest_formattingpass (2/2), including the FreeBSD conversion, secure-path, and surrogate cases; conventions pass. The Windows and FreeBSD differential runs in the issue report were not repeated locally.