fix(libc): print %lp in the wide formatter as measured on a PS5 #11214
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11214"
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-25T21:56:01Z.
What
The wide formatter's
_sfunctions (snwprintf_s,vswprintf_s,vfwprintf_sand the rest that passsecure = true) now print%lpas they print%p; until now they returned -1. Since #11893 the plain functions (swprintf,vswprintf) already drop the length on%pbefore this branch. The systemlibSceLibcInternalof a retail PS5 (firmware 13.60) prints%lpas%pthroughswprintf. No_sfunction was run with%lpon a console: they followswprintfand the narrow_sforms here, and the debt entry says so. Measured with a homebrew probe from a payload process; the source and console log are in this gist (pfmtp).On the console:
swprintfof[%lp]gives[1f](return 4) for0x1f, and[0](return 3) for null, exactly as[%p]does.[%ls]of a mixed string prints it unchanged.The cases the debt entry listed as unmeasured, through
snprintf:%.0p:%5.0pof null gives five spaces;0flag beside a precision:%05.3pof0x1fgives01f;%.0pof a non-null pointer gives1f.-,#,%20pand the null%pgive1f,1f, 18 spaces then1f, and0. That is what AnyPS5's shared pointer formatter already prints.Another length on
%p, such as%hp, follows #11893 (merged), which ignores it in the plain forms as titles'libc.prxdoes. The debt entry now records the measured cases.Before and after
swprintf[%lp]of0x1f[1f], returns 4[1f], returns 4 since #11893swprintf[%lp]of null[0], returns 3[0], returns 3 since #11893snwprintf_s[%lp]of0x1f[1f], returns 4snwprintf_s[%lp]of null[0], returns 3%5.0p,%05.3p,%.0pand the other%pflags%hpand other lengthsTested
Windows 11, WinLibs GCC 15.2. The 13 tests matching
formatpass 3 times out of 3.guest_wide_formattingnow checks:[%lp]gives[1234](6) and[0](3);[%5.0p][%05.3p][%.0p]gives[ ][ 01f][1f](18).tools/check_conventions.pypasses. Heade2bbf70239onmain88f99678bf. After mergingmain(2cce8bc51d, which brought #9927), head3315252passesguest_wide_formatting3 times out of 3 on Windows (GCC 15.2) and on Linux (WSL Ubuntu, GCC), andcheck_conventionsreports no errors. After mergingmain(899ae3d1ad, which brought #11893 and its own%lpand%hphandling; the[%hp]returns -1 check was dropped and the debt entry points to the length modifiers entry), head382120ba67passesguest_formattingandguest_wide_formatting3 times out of 3 on Windows (GCC 15.2) and on Linux (WSL Ubuntu, GCC), andcheck_conventionsreports no errors. Head246110e525addssnwprintf_s%lpchecks for0x1fand null:guest_formattingandguest_wide_formattingpass 3 times out of 3 on Windows (GCC 15.2) and on Linux (WSL, GCC 16.2), run at813cbd96bb;246110e525changes only the debt text. Without theFormattingWide.cppchange the new check fails withsnwprintf_s %lp prints the pointer as %p does.check_conventionspasses.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)swprintf("%lp")to fail, which this measurement contradicts), #9927, #9958 and #10379 (they edit the debt entries next to this one); merge order only; #11907 and #12397 (JJenkx) rewrite the same%lpcheck inGuestWideFormatting.cpp(merge order only)