fix(libc): use guest pointer formatting on Linux #6483
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6483"
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 casualmelatonin on 2026-10-15T17:06:10Z.
What
Route Linux narrow printf-family formats containing
%pthrough the existing shared guest formatter. Previously a null pointer could print(nil)in a narrow format but0x0when a wide conversion selected the shared formatter. Rename the selector toRequiresGuestFormattingand update its callers, including allocating, stream and argument-list forms.Enable the existing pointer-formatting cases on Linux and add regressions for mixed wide/pointer formats, escaped percent signs, positional width/precision, mixed integer/floating-point arguments, argument-list and secure wrappers, truncation,
%nand allocating output. Update the libc debt entry, retaining the unverified console behavior and the remaining host-only NaN discrepancy.Reference behavior: FreeBSD 11.4 vfprintf. The existing pointer formatter supplies lowercase hexadecimal with a
0xprefix. No PS5 measurement is claimed.Overlap reviewed: no duplicate Linux pointer-routing change found. #3987 extends shared formatter conversions, #5303 changes the wide family, and #6315 changes secure formatting constraints. #6315 touches two selector callers and may require a rebase when either PR merges; merge order still needs confirmation with its author. #6044 reorganizes tests and may require relocating these regression cases. Other shared test/debt paths reported by the overlap check concern separate behavior. No functional dependency is required for the conversions covered here.
Tested
Local checks and an independently reported Linux runtime run are separated below. Maintainer full Linux/Windows Build workflow checks remain pending.
BUILD_TESTING=ON, headcf5e89015applied tomain03c4cb5. The PR's tests on the original source failguest_formatting; with the fix,guest_formattingandguest_wide_formattingpass. Additional mixed-conversion probes matched glibc apart from the documented NaN behavior. The 649-test non-GPU suite matched main, with the same two pre-existing file-writer failures.FormatPointerandFormatOutputbodies: 83/83 passed with C++20, warnings as errors, AddressSanitizer and UndefinedBehaviorSanitizer. The original selector fromorigin/mainfails the 15 pointer-routing assertions in the same harness. These are helper checks, not guest ABI tests; the harness was kept outside the repository.Formatting.cppcompiled and linked into an x86-64 Mach-O harness; modifiedcore/libs/tests/Formatting.cpppassed x86-64 syntax checking. An external Darwin compatibility shim was used for existing platform macros and GCC varargs builtins. No repository compatibility shim was added. The x86 binary could not run because Rosetta is unavailable.tools/check_conventions.py --base origin/main: passed with bundled Python 3;git diff --check: passed.BUILD_TESTING=ON: blocked by uninitialized third-party submodules. Linux/Windows guest runtime tests were not run locally; Windows and game/console behavior remain unverified here. A maintainer-triggered full Build workflow is still needed.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T17:29:17Z.
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.
docs/dev/debt/libc.mdcore/libs/tests/Formatting.cppdocs/dev/debt/libc.mdcore/libs/tests/Formatting.cppcore/libs/tests/Formatting.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/tests/Formatting.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/Formatting.cppcore/libs/tests/Formatting.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/Formatting.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/tests/Formatting.cppcore/libs/tests/Formatting.cppdocs/dev/debt/libc.mdcore/libs/prx/libc/src/Formatting.cppcore/libs/tests/Formatting.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/Formatting.cppcore/libs/tests/Formatting.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/Formatting.cppcore/libs/tests/Formatting.cppdocs/dev/debt/libc.mdImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T18:09:35Z.
Review: COMMENTED
Linux run, since the Tested section is empty and the change only affects Linux.
Ubuntu 26.04, i7-8700, gcc 15.2 (glibc host), Release,
BUILD_TESTING=ON, full build. Headcf5e89015applied onmain03c4cb5e7.Formatting.cpptest onmain's source):guest_formattingfails withFormatting check failed. The pointer checks that used to be Windows-only now run on Linux.guest_formattingandguest_wide_formattingpass.%p, the rest of it now goes through the shared formatter on Linux too, so I compared each conversion with glibc. These all match glibc's output:%lld %zu %hd %hhd %jd %.3f %e %g %a %Lf %s %5.2s %c %x %X %#o.printfandlibc_printfprint0x0|5|xfor"%p|%d|%s"with a null pointer. The only difference is the documented NaN one, and it now depends on the format."%p %f"with-nanprintsnan, while"%f"alone still prints-nan, and+/space are honored only without%p.-E "^agc|gpu|vulkan|video_out",-j8): same result asmain. Onlyfile_writer_binaryandfile_writer_textfail, onmaintoo (this host's coreutils rejects the command they run).Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T17:59:40Z.
A new PS5 payload probe in issue #7549 measured
snprintf/swprintffromlibSceLibcInternal.sprx:%pemits bare lowercase hex (0for null), without0x, and#does not add a prefix. PR #6483 currently routes Linux narrow%pthroughFormatPointer, whose output still has0x. The probe is for the systemlibSceLibcInternal.sprxin a payload process, not a title-bundledlibc.prx, so scope may differ; I’m sharing it because the PR currently records console behavior as unmeasured. I would not change this branch based on that evidence alone without deciding which guest libc/API behavior this formatter is intended to model.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T18:25:10Z.
Thanks @casualmelatonin, this change landed as part of #7562 (the same Linux selector change and rename), so I'm closing this as included.
Pull request closed