Repository navigation
fix(libc): format guest wide printf arguments on Linux - #1804
Merged
oneandonlydean merged 1 commit intoOct 10, 2026
Merged
Conversation
|
Tested on Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release,
|
This was referenced Oct 9, 2026
9 tasks done
oneandonlydean
added a commit
to oneandonlydean/AnyPS5
that referenced
this pull request
Oct 10, 2026
oneandonlydean
added a commit
to oneandonlydean/AnyPS5
that referenced
this pull request
Oct 10, 2026
SleglJan
pushed a commit
to SleglJan/AnyPS5
that referenced
this pull request
Oct 10, 2026
…intf fix(libc): format guest wide printf arguments on Linux
10 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On Linux the narrow printf family passes
%ls/%Sguest strings to the host formatter, which reads 32-bit wchar_t elements instead of the guest's 16-bit units. Route formats containing%ls,%S,%lcor%Cthrough the existing guest formatter. Formats without guest wide conversions retain their native Linux path, including positional arguments and escaped percent signs. Guest va_list inputs remain unchanged.The common formatter also dropped a NUL
%lc/%Cargument because it passed that character through%s. Format that one case through%c, preserving the byte and output count. This follows FreeBSD 11 vfprintf, whose wide-character branch emits the completewcrtombresult, including a converted NUL.Extend the existing guest_formatting regression on both platforms and update TechnicalDebt. The UTF-16-to-UTF-8 conversion policy is the existing Windows policy: it does not establish console locale behavior or validate invalid UTF-16. Positional or other unsupported conversions in a format that needs the guest formatter still throw; ordinary Linux formats keep host support.
Independent of #1507 (wcsrtombs), #1511 (swprintf), #1573 (Windows numeric flags), #1614 (locale character conversions) and #1708 (large collate storage). Merge simulations with the current heads of #1511 and #1573 are clean. #1708 conflicts only in adjacent TechnicalDebt entries; the implementation files merge cleanly. Rebase the second PR after the first merges, preserving both debt updates. No functional dependencies.
Tested
Windows x64 Release, portable GCC 15.2.0 and CMake/Ninja in the existing virtualenv, SPIRV-Tools disabled: all 34 libc CTests pass. The real-DLL PoC covers all 14 formatting exports, C and UTF-8 host locales, mixed argument types, output capacities, precision, Unicode surrogate pairs, NUL characters, protected page boundaries, allocation and file/stdout output, preserved va_list state and concurrent calls.
Linux validation on Ubuntu 24.04, GCC 13.3, Release, SPIRV-Tools enabled, exact commit
21d21da3857e: the same regression on unpatched main fails only guest_formatting (36/37 tests pass). The fix passes 37/37 libc tests, repeated three times. The full suite, requested with repeat until-fail:3, has 291 passes, 194 GPU-dependent skips and 1 failure(s) out of 486 tests. The complete project, patched libraries and test-registration check pass. The Linux real-library PoC passes 5,974 checks; Windows passes 5,976. Full Windows project suite not rerun for this contribution. Build tools are installed in virtualenvs or taken from the existing portable toolchain; no system installations.The full suite has one failure:
agc_driver_flipreports "failed flip was completed successfully". This is consistent with a pre-existing notification race: QueueWorker.cpp calls ReportFailure before failing the active submission's flip requests; Lifecycle.cpp publishes the exception and wakes idle waiters. Flip.cpp then reads the callback counter after those waiters return, which can happen before the callback. These three files are byte-identical to the unpatched base. This diagnosis is source analysis; the unpatched base was not rerun locally to reproduce the failure. Upstream Build on that base passed, so this result should not be presented as a deterministic base failure. The printf change does not modify the AGC path.Reviewed all 386 open PR file lists and the complete relevant diffs. No other PR implements Linux routing for guest wide printf arguments or the NUL-character correction. No game or original console libc execution.
Checklist