fix(libc): print %p in the FreeBSD form in the Windows printf family #2693
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2693"
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-10T11:02:14Z.
What
On Windows the guest printf family sent
%pto the host CRT, which prints a zero-padded 16-digit value without a prefix:0000000000001234for 0x1234 and0000000000000000for NULL. FreeBSD'svfprintf.c(case 'p') setsox[1] = 'x'unconditionally, so the output always has the0xprefix, lowercase digits, and NULL prints0x0;#,+and space are ignored,-and0and width and precision behave as for an integer conversion (%.0pof NULL prints0x). The widevfwprintf.cis identical. An existing check incore/libs/tests/Formatting.cppcompared the guest output with the host's%pand therefore encoded the old behaviour.LibcDetail::FormatPointer(WindowsFormatting.hpp) builds that form and is used byFormatWindows(snprintf, sprintf, vsnprintf, vfprintf, printf, ...) and byFormatWide(swprintf, wprintf, ...). The Linux narrow path still goes through the host for formats without wide arguments; that is recorded in TechnicalDebt (glibc prints a null pointer as(nil)).Tested
Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release:
guest_formatting(Windows-only narrow%pcases: NULL, a normal value, width,-,0, precision,%.0p, truncation return values) andguest_wide_formatting(wide cases) fail without the change and pass with it.ctest -R "formatting|guest_strings|file_streams|standard_streams"passes.snprintf,sprintf,vsnprintf,swprintf) against a reference of FreeBSD's algorithm, cross-checked against the host%#llx, over 114,336 distinct format specs (all flag subsets and orders, widths, precisions,*forms) x 8 values x buffer sizes 0 to len+7: about 2.8 million calls, 0 divergences, nova_listmutation, no guard-byte overrun.tools/check_conventions.py --base origin/mainpasses;tools/pr_overlap.py --branchreports no overlap.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T11:02:32Z.
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
Pull request closed