feat(libc): implement localeconv #3245
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3245"
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 pushkarreddyy on 2026-10-11T03:25:11Z.
What
Implement
localeconv(NID0hlfW1O4Aa4) inlibc.struct GuestLconvmatching 64-bit ABI layout and member offsets inGuestLocale.hpp.localeconv_nid_postfix()inLocaleSupport.cppreturning the standard classic C locale configuration (.decimal point,""string fields,CHAR_MAX127 integer formatting values).*__error_nid_postfix().GuestLocale.cppunit tests validating struct contents, pointer stability, and guest errno sentinel preservation.docs/dev/TechnicalDebt.md.Resolves runtime stops on
main:PPSA99600) andPPSA17641fail at startup:./app.elf: symbol lookup error: ./app.elf: undefined symbol: 0hlfW1O4Aa4PPSA99808,PPSA99810,PPSA99010,PPSA99728).Tested
GuestLocalechecks pass.python tools/check_conventions.py --base origin/mainreports 0 errors.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 repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T03:25:21Z.
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.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T03:25:33Z.
Progress report (
961b25f→80fb6ab)📈 System libraries: 86.01% (+0.01%, +1 implemented functions)
✅ 1 implemented
localeconv_nid_postfixImported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T06:38:47Z.
The intake check closed this automatically. @oneandonlydean @MarcZX100 @adriadam10: Could one of you please reopen or carry this when convenient? It implements
localeconv(PPSA99600, PPSA17641), tracked in issue #3249. It is cleanly rebased, mergeable onto currentmain(1690db9a2) withMergeable: True, and passes all conventions and unit tests.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-11T09:32:01Z.
Independent localeconv source and runtime validation (2026-10-11, 1642b5c8)
The exact three source/test files from #3245 (
80fb6ab27) were applied to pinned newer main90c152e8, with the debt entry adapted to its context. Original Windowsguest_locale: 5/5 pass, max 0.08 s. #3310 resubmits the same patch; open #545 also implements this libc entry as well as its Ampr re-export (head0647694a), with a materially different SonyLconv layout. Correction after inspecting its actual patch: its title/body do not fully describe the libc changes. The FreeBSD-based adaptation below is a validation branch, not a competing new PR.Two qualified observations against FreeBSD 11.4
d1060029:{CHAR_MAX,0}for grouping/mon_grouping, returned directly by localeconv.c. This PR uses empty strings. Both mean no grouping under C semantics; this is a raw FreeBSD representation difference, not proof of a PS5 fault or a portable-C semantic defect.-funsigned-charreturns 255 in the unavailable byte fields; the independent guest-byte oracle expects 127. Default x86_64 tests pass. This stress check exposes a host assumption, not a demonstrated default-toolchain failure; actual PS5 bytes remain unmeasured.Proposed adaptation and extended tests, fork commit
1642b5c8: explicit byte 127 and FreeBSD-style grouping, all offsets asserted, stable storage, guest errno, four concurrent readers, supported locale selection and rejection, and independence from host locale changes. Existing main already implements restrictedsetlocale: C/POSIX/empty/query succeed; non-C names are unsupported. This implementation covers that existing C-locale domain. PS5 equivalence is debt. Credit to pushkarreddyy's #3245; #3310 identical resubmission; no new dependency.Validation:
guest_locale5/5, max 0.05 s; independent native probe against built libc 5/5 (all 24 offsets and values, stable pointer, actual guest errno/thread checks, accepted German/de_DE host-locale changes).LocaleSupport.cpp+StdioExtras.cpp, 5 normal and 5 unsigned-char probe passes. Linux uses a probe-local TLS errno oracle, not the full Linux runtime/GPU. Five mutants detected: grouping, decimal, sentinel, null result, errno. Grouping mutant checks the chosen FreeBSD bytes, not broader C semantic equivalence.ctest -j4, RTX 5080, Vulkan/MSAA required, shader cache disabled; SPIRV-Tools disabled. Related observations: #3291. Graphics cause unresolved; full suite is not all green.Fork ref/parent and four changed-file Git blobs verified. No PR opened during halted intake. AI-assisted adaptation, tests and investigation: Codex. Game replay with the preserved unlocked-I/O prerequisite follows separately; no gameplay or console-equivalence claim.
Outstanding ABI question: #545 places
decimal_pointat 0x48 behind reserved fields, whereas #3245/FreeBSD places it at 0x00. This source comparison has not established the actual PS5/title ABI. I am checking the title caller before treating either layout as confirmed. The current tests establish consistency with the selected FreeBSD oracle, not console equivalence.Controlled title replay and preserved fork integration (2026-10-11, e22af772)
The original caller ABI question is now narrowed for PPSA99902: four of its five known direct callers read the decimal pointer at result+0; the fifth copies a 96-byte prefix. All original hashes, mapped bytes and five original unwind boundaries checked; Capstone/GNU objdump agree. Ghidra reverified 5/5 full PT_LOAD hashes and import references, but has 0/5 existing caller functions here: no decompiler inference or AI type is used. This supports the FreeBSD-style prefix for this title, not all fields/universal PS5 ABI. Exact addresses/raw instructions and PR #545 comparison.
The experimental carry
e22af772changes only the same four files directly after preserved unlocked-I/O integration8f2b7210; its three locale source/test files exactly match focused1642b5c8. The experimental runtime remains pinned to olderf60923bf, with its existing local prerequisites; the focused branch separately uses newer main90c152e8. Both fork refs/parents/four changed-file blobs are verified; no PR created.Full integration build and 122 libraries pass; 823/828 full-suite tests pass, 5 documented display/no-Vulkan skips, 0 failures, max 16.41 s, global 30 s harness limit,
ctest -j4, Windows 11 / RTX 5080, Vulkan/MSAA required, shader cache off, SPIRV-Tools off. Locale/guest-stream/file-stream tests additionally pass five repeats each. This older integration's green result does not resolve the five aperture failures on the newer-main focused build reported above.Controlled startup: same fresh
app-main-f609.exeand guest-libc conversion throughout. Before: missing localeconv in 0.144 s. Replace only libc, preserving exact hashes of all other 121 libraries: 5/5 runs advance to missingfminf(uVRcM2yFdP4, libSceLibcInternal), 0.117–0.125 s. Complete rebuilt integration: 5/5 reproduce the same fminf stop, 0.116–0.123 s. Every run exits0xC0000139, no timeout, before guest entry. Exact 123-library baseline/guest module restored; original ELF/guest-libc hashes unchanged. NID database, independent name hash and runtime export audit confirm the symbols/provider change. This demonstrates loader progress, not localeconv invocation or game startup success.Next: independently validate existing closed/unmerged #1770 and #2280 implementations of fminf, including signed-zero/NaN/exception behavior. Neither math PR has been tested by us yet. AI-assisted adaptation, validation and reporting: Codex.
Older FreeBSD proposal no longer carried in current integration (2026-10-11)
Fresh main0f863 integration retains upstream's merged Sony CRT0x90-byte locale structure and does not carry our earlier FreeBSD offset0 override. With math/kernel prerequisites it enters PPSA99902 guest; the controlled D64-only driver change advances5/5 to #3036. The old override is therefore not established as necessary for this newer startup stack. Current Sony-source probe, tests, vendor observation and unresolved guest-caller ABI distinction.
The original FreeBSD source/caller evidence and tests remain historical scoped evidence, not proof that one FreeBSD structure universally implements PS5 localeconv. Current Sony prefix pointers are non-null empty monetary strings, so previous null-fallback reasoning does not cover this version. We should settle actual guest/toolchain ABI expectations rather than replace the vendor layout to fit one target. No new PR; AI-assisted validation/report: Codex.
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T11:03:37Z.
Thank you so much @Amoenus for the meticulous runtime disassembly analysis and 5/5 title replay validation on Sonic Unleashed Recompiled (
PPSA99902)!Confirming that the title callers read
decimal_pointdirectly at offset0x00firmly validates the FreeBSD 11 ABI prefix layout. Your extensive multi-platform verification across Windows (GCC 15.2 / RTX 5080) and Linux, as well as narrowing the subsequent stop tofminf(uVRcM2yFdP4), is invaluable. Much appreciated!Pull request closed