libc: the Windows printf family aborts on %qd, %D, %O, %U, unknown conversions and a trailing % that FreeBSD formats; fix branch ready #3975
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-11T20:20:18Z.
On Windows, the guest
printffamily (FormatWindows) throws and aborts the guest on four things FreeBSD 11.4vfprintf.cformats:qlength modifier (%qd,%qu,%qx)%D,%Oand%Uconversions (synonyms for%ld,%lo,%lu)-flag (%y,%5%,%-5y)%, where FreeBSD stops (snprintf("100%")returns 3)Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/libc-format-freebsd-conversions (two commits on current main: the change, then a correction found in review;
libc/include/WindowsFormatting.hpp,tests/Formatting.cpp, oneTechnicalDebt.mdentry). The unknown-conversion branch skips every character that FreeBSD'svfprintfhandles itself (taken from the 11.4caselabels), so%m,%1$d,%'d,%l5d,%lqdand%qckeep throwing as before instead of printing wrong output.Checks:
guest_formattingcases fail on main (abort) and pass with the change, including a loop that expects the unsupported forms above to still throw;guest_wide_formatting,file_streamsandguest_standard_streampass.%m,%1$d,%'dand modifiers in odd order; the second commit fixes that and the last review was clean.check_conventions.pyis clean andpr_overlap.pyfinds no overlap; #3566, #3567 and #3569 also edit this file in other places, so a textual rebase may be needed.Not fixed here, the same on main:
%05%,%05y,%05sand%05cpad with blanks where FreeBSD pads with zeros (listed inTechnicalDebt.md);% uprints a leading space;%.1lcapplies the precision;%jp,%qs,%hhs, doubled lengths such as%lhand%qqare rejected;%mand positional%1$dare unsupported (the last is #3569). Only Windows was built and run; the Linux glibc path still prints%D,%O,%Uand unknown conversions as written. The reference is the FreeBSD source, not a console.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T07:22:23Z.
Windows test of the fix branch (
husseinkad:fix/libc-format-freebsd-conversions,0e3b2896d+0106858d3) merged onto current upstream/maind146ec1b6(Windows 10, WinLibs GCC 15.2, Release; builtguest_formatting_tests,guest_wide_formatting_tests,file_streams_tests,guest_standard_stream_tests):guest_wide_formatting,file_streamsandguest_standard_streamspass.guest_formattingfails (Formatting check failedatcore/libs/tests/Formatting.cpp:187, the loop over the formats that must still throw). The format that no longer throws is%1$d: main now handles positional arguments (#3569,b9fc44834), and also the'flag (#3567,d9fe7ee61), so the branch's list{"%m", "%1$d", "%'d", ...}is stale. With"%1$d"and"%'d"removed from that list locally (nothing else changed), all four tests pass, including the new%qd,%D/%O/%U, unknown-conversion and trailing-%cases.python tools/check_conventions.py --base upstream/mainpasses on the merge.lib/libc/stdio/vfprintf.c(releng/11.4):case 'q'setsLLONGINT,D/O/UsetLONGINTand fall through tod/o/u, and the default case prints the character itself and stops on NUL (goto done); that matches the branch's behaviour as I read it. I did not rerun the reporter's differential fuzz.So the branch needs the two stale entries dropped from the test list before it can go in on current main. Not tested: Linux.
AI-assisted (Claude Code).