feat(libc): wire the codecvt<wchar_t,char> facet vtable #11172

Closed
00xDisaster wants to merge 5 commits from upstream-pr/11172 into main
00xDisaster commented 2026-10-25 20:33:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-25T20:33:21Z.


What

Wire the exported codecvt<wchar_t,char,_Mbstatet> vtable. #10180 added the thirteen-slot _ZTVSt7codecvtIwc9_MbstatetE_nid_postfix data object (NID H-TDszhsYuY, st_size 104) with every slot zero, so a title that resolved the object and called in, out or unshift faulted. Slots 2 through 11 now hold the same facet methods and conversion virtuals that the console uses; slot 12 (length) throws.

The slot order and the conversion behaviour come from the libc.prx bundled with PPSA03446; the size and facet layout were already recorded from PPSA26344 and libSceLibcInternal.sprx. Slots 2 to 5 are the facet destructor, deleting destructor, retain and release; slot 6 returns false for always_noconv; slot 7 returns 6 for max_length; slot 8 returns 0 for encoding; slots 9 to 12 are in, out, unshift and length. The console's in and out delegate to its _Mbtowcx and _Wctombx, so this port does the same through the guest UTF-8 helpers: in decodes one- to three-byte UTF-8, out encodes one to three bytes, four-byte leads are invalid, a partial output buffer returns partial, an invalid sequence returns error, and unshift clears the state.

The length slot throws instead of returning a character count. Standard do_length consumes input bytes rather than wide characters, and no disassembly or console run established this module's return value or its state effect, so the slot stays unsupported until that evidence exists. The debt entry records the gap.

_Mbtowcx and _Wctombx previously used the host mbrtowc/wcrtomb, which depends on the host C locale and cannot produce the guest's three-byte UTF-8. They now use the guest helpers, and _Getpmbstate and _Getpwcstate reserve the 16-byte conversion state those helpers read and write. Slots 0 and 1 remain zero, as they were; the debt entry records that and the console's relocated offset-to-top and typeinfo entries.

This does not change the narrow codecvt<char> object in #10165, the num_put work in #11054, the collate<char> object in #11166, or the fgetwc surrogate handling in #10929, and no open PR implements these wide conversion virtuals. The only overlap is textual: #10165 resizes and moves the adjacent narrow codecvt declaration, so whichever lands second needs a rebase; this PR is listed after #10165 so the older change can land first.

Tested

Linux CachyOS 7.3.0-4-cachyos, GCC 16.2.1. Base upstream/main 0836dfdf4fecb1e0326100c490476e15d3a74da5; head 597258ffad.

  • cmake --build build --target guest_locale_tests guest_multibyte_locale_tests guest_wide_conversion_tests guest_wide_formatting_tests guest_wide_string_tests guest_wide_stream_scan_tests --parallel: passed.
  • ctest --test-dir build -R '^(guest_locale|guest_multibyte_locale|guest_wide_formatting|guest_wide_strings|guest_wide_conversion|guest_wide_stream_scan)$' --output-on-failure: 6/6 passed after the rebase.
  • guest_locale calls the exported vtable's in, out and unshift, checks ASCII, two- and three-byte UTF-8, an incomplete lead completed by the next call, a partial output buffer, an invalid four-byte lead, the facet retain/release slots, and that slots 0 and 1 stay zero. It calls length and asserts that it throws.
  • tools/check_conventions.py --base upstream/main --head HEAD and git diff --check upstream/main..HEAD: clean.
  • The two macOS write-watch jobs fail before building this PR: core/libs/tests/write_watch/CMakeLists.txt registers write_watch_execute-fault and write_watch_read-fault twice. The same duplicate loop is present on upstream/main; this PR does not touch that file, so it is a base-branch CI issue rather than an effect of this change.
  • Windows 11 26300, WinLibs GCC 15.2.0, Release (maskym, independent run on an earlier head): build clean; guest_locale passed in a joint 160/160 run of the libc, CesCs, Font, FreeType, LibreSsl3 and NpUniversalDataSystem suites. That run predates the refresh; the refreshed head is tested on Linux above. Not run on a PS5.
  • GPUs tested: n/a.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: no
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5008430644 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11172). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-25T20:33:21Z. --- ### What Wire the exported `codecvt<wchar_t,char,_Mbstatet>` vtable. #10180 added the thirteen-slot `_ZTVSt7codecvtIwc9_MbstatetE_nid_postfix` data object (NID `H-TDszhsYuY`, `st_size` 104) with every slot zero, so a title that resolved the object and called `in`, `out` or `unshift` faulted. Slots 2 through 11 now hold the same facet methods and conversion virtuals that the console uses; slot 12 (`length`) throws. The slot order and the conversion behaviour come from the `libc.prx` bundled with PPSA03446; the size and facet layout were already recorded from PPSA26344 and `libSceLibcInternal.sprx`. Slots 2 to 5 are the facet destructor, deleting destructor, retain and release; slot 6 returns false for `always_noconv`; slot 7 returns 6 for `max_length`; slot 8 returns 0 for `encoding`; slots 9 to 12 are `in`, `out`, `unshift` and `length`. The console's `in` and `out` delegate to its `_Mbtowcx` and `_Wctombx`, so this port does the same through the guest UTF-8 helpers: `in` decodes one- to three-byte UTF-8, `out` encodes one to three bytes, four-byte leads are invalid, a partial output buffer returns `partial`, an invalid sequence returns `error`, and `unshift` clears the state. The `length` slot throws instead of returning a character count. Standard `do_length` consumes input bytes rather than wide characters, and no disassembly or console run established this module's return value or its state effect, so the slot stays unsupported until that evidence exists. The debt entry records the gap. `_Mbtowcx` and `_Wctombx` previously used the host `mbrtowc`/`wcrtomb`, which depends on the host C locale and cannot produce the guest's three-byte UTF-8. They now use the guest helpers, and `_Getpmbstate` and `_Getpwcstate` reserve the 16-byte conversion state those helpers read and write. Slots 0 and 1 remain zero, as they were; the debt entry records that and the console's relocated offset-to-top and typeinfo entries. This does not change the narrow `codecvt<char>` object in #10165, the `num_put` work in #11054, the `collate<char>` object in #11166, or the `fgetwc` surrogate handling in #10929, and no open PR implements these wide conversion virtuals. The only overlap is textual: #10165 resizes and moves the adjacent narrow codecvt declaration, so whichever lands second needs a rebase; this PR is listed after #10165 so the older change can land first. ### Tested Linux CachyOS 7.3.0-4-cachyos, GCC 16.2.1. Base `upstream/main` `0836dfdf4fecb1e0326100c490476e15d3a74da5`; head `597258ffad`. - `cmake --build build --target guest_locale_tests guest_multibyte_locale_tests guest_wide_conversion_tests guest_wide_formatting_tests guest_wide_string_tests guest_wide_stream_scan_tests --parallel`: passed. - `ctest --test-dir build -R '^(guest_locale|guest_multibyte_locale|guest_wide_formatting|guest_wide_strings|guest_wide_conversion|guest_wide_stream_scan)$' --output-on-failure`: 6/6 passed after the rebase. - `guest_locale` calls the exported vtable's `in`, `out` and `unshift`, checks ASCII, two- and three-byte UTF-8, an incomplete lead completed by the next call, a partial output buffer, an invalid four-byte lead, the facet retain/release slots, and that slots 0 and 1 stay zero. It calls `length` and asserts that it throws. - `tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check upstream/main..HEAD`: clean. - The two macOS `write-watch` jobs fail before building this PR: `core/libs/tests/write_watch/CMakeLists.txt` registers `write_watch_execute-fault` and `write_watch_read-fault` twice. The same duplicate loop is present on `upstream/main`; this PR does not touch that file, so it is a base-branch CI issue rather than an effect of this change. - Windows 11 26300, WinLibs GCC 15.2.0, Release (maskym, independent run on an earlier head): build clean; `guest_locale` passed in a joint 160/160 run of the libc, CesCs, Font, FreeType, LibreSsl3 and NpUniversalDataSystem suites. That run predates the refresh; the refreshed head is tested on Linux above. Not run on a PS5. - GPUs tested: n/a. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: no
MarcZX10 commented 2026-10-25 20:42:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:42:10Z.

Review: COMMENTED


I reviewed head 6ad55bff263cb8a47ce17a2c9391b9eacc4bfbba, including the wide facet slot layout, UTF-8 conversion loops, partial-input continuation, output buffer handling, and the 16-byte guest conversion-state storage. The new tests exercise the vtable and the relevant one-, two-, and three-byte cases. I did not find a concrete correctness issue in the reviewed changes.

Independent checks here: C++20 syntax compilation of LocaleSupport.cpp and GuestLocale.cpp, plus git diff --check upstream/main...HEAD, passed. The author reports the six focused locale suites passed. Hosted conventions, labels, and report checks now pass; I do not see hosted product-build results on this head. I’m leaving a comment-only review pending runtime/build evidence rather than approving without it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645168217 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11172#pullrequestreview-5645168217). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T20:42:10Z. **Review:** COMMENTED --- I reviewed head `6ad55bff263cb8a47ce17a2c9391b9eacc4bfbba`, including the wide facet slot layout, UTF-8 conversion loops, partial-input continuation, output buffer handling, and the 16-byte guest conversion-state storage. The new tests exercise the vtable and the relevant one-, two-, and three-byte cases. I did not find a concrete correctness issue in the reviewed changes. Independent checks here: C++20 syntax compilation of `LocaleSupport.cpp` and `GuestLocale.cpp`, plus `git diff --check upstream/main...HEAD`, passed. The author reports the six focused locale suites passed. Hosted conventions, labels, and report checks now pass; I do not see hosted product-build results on this head. I’m leaving a comment-only review pending runtime/build evidence rather than approving without it.
MarcZX10 commented 2026-10-29 07:12:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T07:12:11Z.

Review: CHANGES_REQUESTED


Re-checked — new head, changes still requested

The independent Windows guest_locale result is helpful, but both the PR and that result use base 74ac0e7912, while current main changed the locale implementation, tests, and debt file.

What I ran

  • Reviewed exact PR head 6ad55bff26 against current main edf6804cf52c62eacafc592dd6142cb4efe5bd05.
  • Ran git merge-base, git merge-tree --write-tree, git diff --name-status for shared paths, and git diff --check.
  • Checked current hosted workflow results. I did not execute locale tests locally.

Results

Check Result
PR base / current main 74ac0e7912 / edf6804cf5
Merge preview Clean; tree 7dbdf8329a4897de163318daeca6595e2599c8e9
Current-main changes on PR paths LocaleSupport.cpp, GuestLocale.cpp, and docs/dev/debt/libc.md
Diff check Passed; no output
Hosted conventions, labels, eligibility, report, relinker, ASan, register-context, write-watch Passed
Hosted product Windows/Linux jobs Skipped
Author-reported Windows result guest_locale passes as part of the 160-test locale/library suite on the PR head, but its integration base predates current main
Unedited available command output
$ git merge-base upstream/main refs/review/upstream-11172
74ac0e7912a5eaa453fff872f4d4fe803154b08c
$ git merge-tree --write-tree upstream/main refs/review/upstream-11172
7dbdf8329a4897de163318daeca6595e2599c8e9
$ git diff --name-status 74ac0e7912..upstream/main -- core/libs/prx/libc/src/LocaleSupport.cpp core/libs/tests/GuestLocale.cpp docs/dev/debt/libc.md
M core/libs/prx/libc/src/LocaleSupport.cpp
M core/libs/tests/GuestLocale.cpp
M docs/dev/debt/libc.md
$ git diff --check upstream/main...refs/review/upstream-11172

$ gh pr checks 11172 -R boykopovar/AnyPS5
conventions	pass	38s
eligibility	pass	4s
labels	pass	9s
register-context (macos-15-intel, Debug)	pass	1m18s
register-context (macos-15-intel, Release)	pass	1m5s
register-context (ubuntu-latest, Debug)	pass	28s
register-context (ubuntu-latest, Release)	pass	25s
relinker (macos-latest, clang++)	pass	3m40s
relinker (macos-latest, clang++, x86_64)	pass	2m34s
relinker (ubuntu-latest, g++)	pass	3m39s
relinker (windows-latest, g++)	pass	4m32s
relinker-asan	pass	2m23s
write-watch (macos-15)	pass	36s
linux	skipping	0
windows	skipping	0
report	pass	31s
write-watch (macos-15-intel)	pass	1m4s

Negative control

Check Result
New test against current-main base Not run; the available author result is for the earlier base

Findings

Blocking

  • Please rebase on current main and rerun guest_locale on the exact refreshed base and head. Main changed the locale implementation and the shared regression test since 74ac0e7912, so the earlier result does not verify the current integration.

Non-blocking

  • None found in the clean merge preview.

Sources

Not verified

  • The exact-head locale result after integrating current main.

To get this to a good state

  • Refresh the branch, run and report guest_locale on current base and change, and update the exact commit hashes in the description.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5694072489 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11172#pullrequestreview-5694072489). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T07:12:11Z. **Review:** CHANGES_REQUESTED --- # Re-checked — new head, changes still requested The independent Windows `guest_locale` result is helpful, but both the PR and that result use base `74ac0e7912`, while current `main` changed the locale implementation, tests, and debt file. ## What I ran - Reviewed exact PR head `6ad55bff26` against current `main` `edf6804cf52c62eacafc592dd6142cb4efe5bd05`. - Ran `git merge-base`, `git merge-tree --write-tree`, `git diff --name-status` for shared paths, and `git diff --check`. - Checked current hosted workflow results. I did not execute locale tests locally. ## Results | Check | Result | |---|---| | PR base / current main | `74ac0e7912` / `edf6804cf5` | | Merge preview | Clean; tree `7dbdf8329a4897de163318daeca6595e2599c8e9` | | Current-main changes on PR paths | `LocaleSupport.cpp`, `GuestLocale.cpp`, and `docs/dev/debt/libc.md` | | Diff check | Passed; no output | | Hosted conventions, labels, eligibility, report, relinker, ASan, register-context, write-watch | Passed | | Hosted product Windows/Linux jobs | Skipped | | Author-reported Windows result | `guest_locale` passes as part of the 160-test locale/library suite on the PR head, but its integration base predates current `main` | <details><summary>Unedited available command output</summary> ```text $ git merge-base upstream/main refs/review/upstream-11172 74ac0e7912a5eaa453fff872f4d4fe803154b08c $ git merge-tree --write-tree upstream/main refs/review/upstream-11172 7dbdf8329a4897de163318daeca6595e2599c8e9 $ git diff --name-status 74ac0e7912..upstream/main -- core/libs/prx/libc/src/LocaleSupport.cpp core/libs/tests/GuestLocale.cpp docs/dev/debt/libc.md M core/libs/prx/libc/src/LocaleSupport.cpp M core/libs/tests/GuestLocale.cpp M docs/dev/debt/libc.md $ git diff --check upstream/main...refs/review/upstream-11172 $ gh pr checks 11172 -R boykopovar/AnyPS5 conventions pass 38s eligibility pass 4s labels pass 9s register-context (macos-15-intel, Debug) pass 1m18s register-context (macos-15-intel, Release) pass 1m5s register-context (ubuntu-latest, Debug) pass 28s register-context (ubuntu-latest, Release) pass 25s relinker (macos-latest, clang++) pass 3m40s relinker (macos-latest, clang++, x86_64) pass 2m34s relinker (ubuntu-latest, g++) pass 3m39s relinker (windows-latest, g++) pass 4m32s relinker-asan pass 2m23s write-watch (macos-15) pass 36s linux skipping 0 windows skipping 0 report pass 31s write-watch (macos-15-intel) pass 1m4s ``` </details> ## Negative control | Check | Result | |---|---| | New test against current-main base | Not run; the available author result is for the earlier base | ## Findings ### Blocking - Please rebase on current `main` and rerun `guest_locale` on the exact refreshed base and head. Main changed the locale implementation and the shared regression test since `74ac0e7912`, so the earlier result does not verify the current integration. ### Non-blocking - None found in the clean merge preview. ## Sources - [Author’s Windows test update](https://github.com/boykopovar/AnyPS5/pull/11172#issuecomment-6462404223) - [Current-main locale support](https://github.com/boykopovar/AnyPS5/blob/edf6804cf52c62eacafc592dd6142cb4efe5bd05/core/libs/prx/libc/src/LocaleSupport.cpp) - [Current-main locale regression test](https://github.com/boykopovar/AnyPS5/blob/edf6804cf52c62eacafc592dd6142cb4efe5bd05/core/libs/tests/GuestLocale.cpp) - [PR-head locale change](https://github.com/boykopovar/AnyPS5/blob/6ad55bff26/core/libs/prx/libc/src/LocaleSupport.cpp) ## Not verified - The exact-head locale result after integrating current `main`. ## To get this to a good state - Refresh the branch, run and report `guest_locale` on current base and change, and update the exact commit hashes in the description.
XairRrR commented 2026-10-29 11:34:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T11:34:57Z.

Review: APPROVED


Reviewed — approved

The refreshed head merges cleanly into current main, builds, passes the six locale suites, and the new guest_locale checks fail against main's LocaleSupport.cpp. I found nothing blocking.

What I ran

Head fdc62fb1048cd66e6969b1e4819f53d979ec1ca3 merged with --no-ff into main ba5b5330b37724bca4b99f30faab504653635a04 in a clean worktree. Release, GCC 16.2.1, Ninja, BUILD_TESTING=ON. Arch Linux 7.2.11-zen, Intel Core i9-14900KF.

git merge --no-ff --no-edit refs/review/11172
git diff --check origin/main...refs/review/11172
python3 tools/check_conventions.py --base origin/main
cmake --build build -j10 --target guest_locale_tests guest_multibyte_locale_tests guest_wide_conversion_tests guest_wide_formatting_tests guest_wide_string_tests guest_wide_stream_scan_tests libc
cmake --build build -j10 --target libs
ctest --test-dir build -j4 -R '^(guest_locale|guest_multibyte_locale|guest_wide_formatting|guest_wide_strings|guest_wide_conversion|guest_wide_stream_scan)$' --output-on-failure
# negative control
git checkout origin/main -- core/libs/prx/libc/src/LocaleSupport.cpp
cmake --build build -j10 --target guest_locale_tests
ctest --test-dir build -R '^guest_locale$' --output-on-failure
git checkout HEAD -- core/libs/prx/libc/src/LocaleSupport.cpp

Results

Check Result
Merge into current main Clean
git diff --check No output
check_conventions.py All conventions checks passed.
Build of the six locale test targets and libc Passed
Build of libs Passed (1941/1941)
Six focused locale suites 6/6 passed
Negative control (guest_locale against main's LocaleSupport.cpp) Fails as expected
ctest, merged tree
1/6 Test #525: guest_multibyte_locale ...........   Passed    0.00 sec
2/6 Test #526: guest_wide_conversion ............   Passed    0.00 sec
3/6 Test #522: guest_wide_formatting ............   Passed    0.00 sec
4/6 Test #659: guest_locale .....................   Passed    0.00 sec
5/6 Test #523: guest_wide_strings ...............   Passed    0.00 sec
6/6 Test #566: guest_wide_stream_scan ...........   Passed    0.00 sec

100% tests passed out of 6

MarcZX10's blocking item on 6ad55bff26 asked for a rebase and a rerun of guest_locale on current main. This head is rebased, and the run above is on the merge with current main ba5b5330b3, so that item is resolved.

Negative control

I restored only core/libs/prx/libc/src/LocaleSupport.cpp from origin/main and kept the PR's GuestLocale.cpp. After a rebuild, guest_locale aborted with Subprocess aborted (the test's Guest locale check failed). With the merged file restored, it passes again.

ctest, negative control
1/1 Test #659: guest_locale .....................Subprocess aborted***Exception:   0.08 sec
0% tests passed, 1 tests failed out of 1
The following tests FAILED:
	659 - guest_locale (Subprocess aborted)

Findings

Blocking

None.

Non-blocking

  • _Mbtowcx still throws where the description says the console returns a code. See LocaleSupport.cpp:864-871. The description says the console's in delegates to _Mbtowcx and maps its results to partial and error. If so, the console's _Mbtowcx returns -2 for incomplete input and -1 for invalid input instead of aborting. The PR now routes _Mbtowcx through the guest helper, but it still throws on both results. The new tests at GuestLocale.cpp:244-253 lock in the throws for "\xe2", a four-byte lead and "\xc3\x28". The port's in calls mbrtowc_nid_postfix directly, so the facet is unaffected, but a guest that calls _Mbtowcx on a split UTF-8 sequence will abort. The throws were already there before this PR, and docs/dev/debt/libc.md does not list them. Suggested fix: if the PPSA03446 disassembly confirms the codes, return -2 and -1 as the console does and assert those values in the test. Otherwise, add a debt entry for the throwing paths. This can be a follow-up.
  • length returns a character count. WideCodecvtLength returns the number of wide characters, and the test expects 3 for six bytes of input (GuestLocale.cpp:93). The standard do_length returns the number of bytes consumed. Older Dinkumware libraries did count characters, so this may well match the console. The debt entry says "counts characters", but it does not say that this differs from the standard. One sentence there, stating that the console behaviour was confirmed, would keep someone from "fixing" it to return bytes later.
  • Depends on: #10165. The description calls this dependency textual only, and the PR merges and passes cleanly on current main without #10165. Listing it under Depends on may hold this PR back behind an open PR it does not need. Consider none, and keep the rebase note in the text.

Not verified

  • Console behaviour: slot order, the max_length value of 6, partial versus ok when in fills the output after converting some characters, and the character-count length. I have no PPSA03446 libc.prx disassembly to compare against.
  • A Windows build or run (16-bit host wchar_t paths). I ran on Linux only.
  • An ASan build.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5697015731 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11172#pullrequestreview-5697015731). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T11:34:57Z. **Review:** APPROVED --- # Reviewed — approved The refreshed head merges cleanly into current `main`, builds, passes the six locale suites, and the new `guest_locale` checks fail against `main`'s `LocaleSupport.cpp`. I found nothing blocking. ## What I ran Head `fdc62fb1048cd66e6969b1e4819f53d979ec1ca3` merged with `--no-ff` into `main` `ba5b5330b37724bca4b99f30faab504653635a04` in a clean worktree. Release, GCC 16.2.1, Ninja, `BUILD_TESTING=ON`. Arch Linux 7.2.11-zen, Intel Core i9-14900KF. ```sh git merge --no-ff --no-edit refs/review/11172 git diff --check origin/main...refs/review/11172 python3 tools/check_conventions.py --base origin/main cmake --build build -j10 --target guest_locale_tests guest_multibyte_locale_tests guest_wide_conversion_tests guest_wide_formatting_tests guest_wide_string_tests guest_wide_stream_scan_tests libc cmake --build build -j10 --target libs ctest --test-dir build -j4 -R '^(guest_locale|guest_multibyte_locale|guest_wide_formatting|guest_wide_strings|guest_wide_conversion|guest_wide_stream_scan)$' --output-on-failure # negative control git checkout origin/main -- core/libs/prx/libc/src/LocaleSupport.cpp cmake --build build -j10 --target guest_locale_tests ctest --test-dir build -R '^guest_locale$' --output-on-failure git checkout HEAD -- core/libs/prx/libc/src/LocaleSupport.cpp ``` ## Results | Check | Result | |---|---| | Merge into current `main` | Clean | | `git diff --check` | No output | | `check_conventions.py` | `All conventions checks passed.` | | Build of the six locale test targets and `libc` | Passed | | Build of `libs` | Passed (1941/1941) | | Six focused locale suites | 6/6 passed | | Negative control (`guest_locale` against `main`'s `LocaleSupport.cpp`) | Fails as expected | <details><summary>ctest, merged tree</summary> ```text 1/6 Test #525: guest_multibyte_locale ........... Passed 0.00 sec 2/6 Test #526: guest_wide_conversion ............ Passed 0.00 sec 3/6 Test #522: guest_wide_formatting ............ Passed 0.00 sec 4/6 Test #659: guest_locale ..................... Passed 0.00 sec 5/6 Test #523: guest_wide_strings ............... Passed 0.00 sec 6/6 Test #566: guest_wide_stream_scan ........... Passed 0.00 sec 100% tests passed out of 6 ``` </details> MarcZX10's blocking item on `6ad55bff26` asked for a rebase and a rerun of `guest_locale` on current `main`. This head is rebased, and the run above is on the merge with current `main` `ba5b5330b3`, so that item is resolved. ## Negative control I restored only `core/libs/prx/libc/src/LocaleSupport.cpp` from `origin/main` and kept the PR's `GuestLocale.cpp`. After a rebuild, `guest_locale` aborted with `Subprocess aborted` (the test's `Guest locale check failed`). With the merged file restored, it passes again. <details><summary>ctest, negative control</summary> ```text 1/1 Test #659: guest_locale .....................Subprocess aborted***Exception: 0.08 sec 0% tests passed, 1 tests failed out of 1 The following tests FAILED: 659 - guest_locale (Subprocess aborted) ``` </details> ## Findings ### Blocking None. ### Non-blocking - **`_Mbtowcx` still throws where the description says the console returns a code.** See [`LocaleSupport.cpp:864-871`](https://github.com/boykopovar/AnyPS5/blob/fdc62fb1048cd66e6969b1e4819f53d979ec1ca3/core/libs/prx/libc/src/LocaleSupport.cpp#L864-L871). The description says the console's `in` delegates to `_Mbtowcx` and maps its results to `partial` and `error`. If so, the console's `_Mbtowcx` returns -2 for incomplete input and -1 for invalid input instead of aborting. The PR now routes `_Mbtowcx` through the guest helper, but it still throws on both results. The new tests at [`GuestLocale.cpp:244-253`](https://github.com/boykopovar/AnyPS5/blob/fdc62fb1048cd66e6969b1e4819f53d979ec1ca3/core/libs/tests/GuestLocale.cpp#L244-L253) lock in the throws for `"\xe2"`, a four-byte lead and `"\xc3\x28"`. The port's `in` calls `mbrtowc_nid_postfix` directly, so the facet is unaffected, but a guest that calls `_Mbtowcx` on a split UTF-8 sequence will abort. The throws were already there before this PR, and `docs/dev/debt/libc.md` does not list them. Suggested fix: if the PPSA03446 disassembly confirms the codes, return -2 and -1 as the console does and assert those values in the test. Otherwise, add a debt entry for the throwing paths. This can be a follow-up. - **`length` returns a character count.** [`WideCodecvtLength`](https://github.com/boykopovar/AnyPS5/blob/fdc62fb1048cd66e6969b1e4819f53d979ec1ca3/core/libs/prx/libc/src/LocaleSupport.cpp#L309-L322) returns the number of wide characters, and the test expects 3 for six bytes of input (`GuestLocale.cpp:93`). The standard `do_length` returns the number of bytes consumed. Older Dinkumware libraries did count characters, so this may well match the console. The debt entry says "counts characters", but it does not say that this differs from the standard. One sentence there, stating that the console behaviour was confirmed, would keep someone from "fixing" it to return bytes later. - **Depends on: #10165.** The description calls this dependency textual only, and the PR merges and passes cleanly on current `main` without #10165. Listing it under **Depends on** may hold this PR back behind an open PR it does not need. Consider `none`, and keep the rebase note in the text. ## Not verified - Console behaviour: slot order, the `max_length` value of 6, `partial` versus `ok` when `in` fills the output after converting some characters, and the character-count `length`. I have no PPSA03446 `libc.prx` disassembly to compare against. - A Windows build or run (16-bit host `wchar_t` paths). I ran on Linux only. - An ASan build.
MarcZX10 commented 2026-10-30 23:34:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T23:34:43Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The new length implementation and test pin a character-count result even though the PR records that the console behavior was not verified.

What I ran

Reviewed exact head c5f43513fbc745807c08b1a0d3513b476ab8c16e against PR base b44985a3ea80f1e9618f7d925292229bf8f051a7. The individual merge preview against current main fc7c353fbcbc974d6b8af027c2769f9f63357b07 was clean. The reported test base 7fcab08f71e463b1768730a626a0f5472d336708 is the merge base of this head and current main; a comparison across the 106 intervening commits found no changes to the locale source, test, debt, or multibyte helper files. Environment: Debian Linux 6.1.0-54-amd64, x86-64, Python 3.11.2; no compiler or project build was run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11172
gh pr checks 11172 --repo boykopovar/AnyPS5
python3 tools/pr_stack_check.py 11172 --repo boykopovar/AnyPS5
git merge-base 7fcab08f71e463b1768730a626a0f5472d336708 c5f43513fbc745807c08b1a0d3513b476ab8c16e
git fetch --no-tags https://github.com/boykopovar/AnyPS5.git refs/heads/main
gh api repos/boykopovar/AnyPS5/compare/7fcab08f71e463b1768730a626a0f5472d336708...fc7c353fbcbc974d6b8af027c2769f9f63357b07 --jq '[.files[].filename] | map(select(test("^(core/libs/prx/libc/src/LocaleSupport\\.cpp|core/libs/tests/GuestLocale\\.cpp|docs/dev/debt/libc\\.md|core/libs/prx/libc/src/Multibyte\\.cpp|core/libs/prx/libc/include/Api\\.hpp)$")))'
curl -fsSL https://raw.githubusercontent.com/cplusplus/draft/d4d6f38143c1b495aa33b2e5de0e0ec2daa173ca/source/text.tex -o /tmp/cppdraft-text.tex
grep -n -A28 -B1 '\\indexlibrarymember{codecvt}{do_length}' /tmp/cppdraft-text.tex

I also inspected the exact-head WideCodecvtLength, its test assertions, the updated debt entry, the precheck's convention warning, and the author-reported test scope.

Results

Check Result
Diff and conventions Diff check passed. Conventions reported 0 errors and one warning: the new debt entry is 1,072 characters and should state the gap first.
Current-main integration Clean individual merge preview. The reported test base is the current merge base, and the changed locale/test/debt paths have no later main changes.
Hosted CI Eligibility, conventions, labels, library-portability, report, Windows, Ubuntu relinker, Ubuntu register-context, and ASan passed. macOS relinker, macOS register-context, and write-watch jobs were pending; Linux product and specialized Linux checks were skipped.
Author-reported tests The PR reports six focused locale suites passing on code commit 230cc7a59d44c2e6e9001fbae32036d466578216, plus an ASan guest_locale run. I did not independently run them. The current head adds a debt-file update after that code commit.
length behavior The test expects length(..., max=2) to return 2 for the six-byte input Aé€, and max=4 to return 3. The pinned C++ draft defines the result as the number of external characters consumed and specifies the state effect as if do_in were called. The PR's debt entry says the console length behavior was not disassembled.
Local build or tests Not run.
Unedited output from relevant checks

Precheck convention output:

docs/dev/debt/libc.md:238: warning: [debt-length] Technical debt entry over 1000 characters: state the gap first (what differs from the console, what is unverified, what throws) and keep only the behaviour it needs: 1072 characters
1 findings, 0 errors; GitHub shows at most 10 error annotations, the job summary lists all

Precheck aggregate result:

Conclusion: checks failed

The precheck's ABI and test-quality helpers were unavailable in its isolated snapshot (tools/pr_abi_audit.py and tools/pr_test_quality.py were not present there); those helper failures do not establish a PR defect. The source and test were inspected directly.

Stack preview:

# PR stack check — fresh

Target: https://github.com/boykopovar/AnyPS5/pull/11172
Target branch tip: `fc7c353fbcbc974d6b8af027c2769f9f63357b07`
All heads unchanged: **True**
Dependency order: #11172

## Individual merge previews

- PR #11172: **clean** against current base; head `c5f43513fbc745807c08b1a0d3513b476ab8c16e`; changed paths: none reported

## Dependency relationships

No declared PR dependencies were found in the target PR chain.

Hosted checks:

linux	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356578490
relinker-asan	pass	2m31s	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577141
register-context (macos-15-intel, Debug)	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577079
relinker (macos-latest, clang++, x86_64)	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577358
register-context (ubuntu-latest, Debug)	pass	33s	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577183
register-context (ubuntu-latest, Release)	pass	29s	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577062
relinker (windows-latest, g++)	pass	6m38s	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577186
labels	pass	8s	https://github.com/boykopovar/AnyPS5/actions/runs/41141412689/job/124358585825
library-portability	pass	1m45s	https://github.com/boykopovar/AnyPS5/actions/runs/41141416046/job/124356311224
conventions	pass	19s	https://github.com/boykopovar/AnyPS5/actions/runs/41141412567/job/124356304483
relinker (ubuntu-latest, g++)	pass	4m15s	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577235
relinker (macos-latest, clang++)	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577245
register-context (macos-15-intel, Release)	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577203
write-watch (macos-15-intel)	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577152
write-watch (macos-15)	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577069
eligibility	pass	10s	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356311738
report	pass	1m0s	https://github.com/boykopovar/AnyPS5/actions/runs/41141415992/job/124356313581
windows	pass	7m34s	https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577045

Findings

Blocking

WideCodecvtLength returns the number of decoded wide characters and leaves the caller's state unchanged by using a local copy. The new test locks in that behavior. The author’s latest comment acknowledges that the character-count behavior is unverified on the console, while the exact-head implementation and tests still assert it. This remains an unmeasured target-specific assertion, and it differs from the standard codecvt::do_length contract. Please either provide pinned binary/console evidence for the target's return value and state behavior and test those results, or leave this slot throwing and record the unresolved behavior until it is verified, as the repository requires for unknown behavior.

Non-blocking

The debt entry exceeds the convention's 1,000-character guidance and the checker asks that it lead with the unresolved gap. This is a warning, not a check failure.

Sources

Not verified

I did not build or run C++ tests locally or test on a PS5. The six focused suite results and ASan run are author-reported; the current hosted macOS jobs were still pending when checked.

To get this to a good state

Please verify length against the pinned target binary or console, or keep this slot unsupported until its behavior is known. I will rerun the relevant checks against the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5719799689 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11172#pullrequestreview-5719799689). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T23:34:43Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The new `length` implementation and test pin a character-count result even though the PR records that the console behavior was not verified. ## What I ran Reviewed exact head `c5f43513fbc745807c08b1a0d3513b476ab8c16e` against PR base `b44985a3ea80f1e9618f7d925292229bf8f051a7`. The individual merge preview against current `main` `fc7c353fbcbc974d6b8af027c2769f9f63357b07` was clean. The reported test base `7fcab08f71e463b1768730a626a0f5472d336708` is the merge base of this head and current `main`; a comparison across the 106 intervening commits found no changes to the locale source, test, debt, or multibyte helper files. Environment: Debian Linux 6.1.0-54-amd64, x86-64, Python 3.11.2; no compiler or project build was run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11172 gh pr checks 11172 --repo boykopovar/AnyPS5 python3 tools/pr_stack_check.py 11172 --repo boykopovar/AnyPS5 git merge-base 7fcab08f71e463b1768730a626a0f5472d336708 c5f43513fbc745807c08b1a0d3513b476ab8c16e git fetch --no-tags https://github.com/boykopovar/AnyPS5.git refs/heads/main gh api repos/boykopovar/AnyPS5/compare/7fcab08f71e463b1768730a626a0f5472d336708...fc7c353fbcbc974d6b8af027c2769f9f63357b07 --jq '[.files[].filename] | map(select(test("^(core/libs/prx/libc/src/LocaleSupport\\.cpp|core/libs/tests/GuestLocale\\.cpp|docs/dev/debt/libc\\.md|core/libs/prx/libc/src/Multibyte\\.cpp|core/libs/prx/libc/include/Api\\.hpp)$")))' curl -fsSL https://raw.githubusercontent.com/cplusplus/draft/d4d6f38143c1b495aa33b2e5de0e0ec2daa173ca/source/text.tex -o /tmp/cppdraft-text.tex grep -n -A28 -B1 '\\indexlibrarymember{codecvt}{do_length}' /tmp/cppdraft-text.tex ``` I also inspected the exact-head `WideCodecvtLength`, its test assertions, the updated debt entry, the precheck's convention warning, and the author-reported test scope. ## Results | Check | Result | |---|---| | Diff and conventions | Diff check passed. Conventions reported 0 errors and one warning: the new debt entry is 1,072 characters and should state the gap first. | | Current-main integration | Clean individual merge preview. The reported test base is the current merge base, and the changed locale/test/debt paths have no later `main` changes. | | Hosted CI | Eligibility, conventions, labels, library-portability, report, Windows, Ubuntu relinker, Ubuntu register-context, and ASan passed. macOS relinker, macOS register-context, and write-watch jobs were pending; Linux product and specialized Linux checks were skipped. | | Author-reported tests | The PR reports six focused locale suites passing on code commit `230cc7a59d44c2e6e9001fbae32036d466578216`, plus an ASan `guest_locale` run. I did not independently run them. The current head adds a debt-file update after that code commit. | | `length` behavior | The test expects `length(..., max=2)` to return `2` for the six-byte input `Aé€`, and `max=4` to return `3`. The pinned C++ draft defines the result as the number of external characters consumed and specifies the state effect as if `do_in` were called. The PR's debt entry says the console `length` behavior was not disassembled. | | Local build or tests | Not run. | <details><summary>Unedited output from relevant checks</summary> Precheck convention output: ```text docs/dev/debt/libc.md:238: warning: [debt-length] Technical debt entry over 1000 characters: state the gap first (what differs from the console, what is unverified, what throws) and keep only the behaviour it needs: 1072 characters 1 findings, 0 errors; GitHub shows at most 10 error annotations, the job summary lists all ``` Precheck aggregate result: ```text Conclusion: checks failed ``` The precheck's ABI and test-quality helpers were unavailable in its isolated snapshot (`tools/pr_abi_audit.py` and `tools/pr_test_quality.py` were not present there); those helper failures do not establish a PR defect. The source and test were inspected directly. Stack preview: ```text # PR stack check — fresh Target: https://github.com/boykopovar/AnyPS5/pull/11172 Target branch tip: `fc7c353fbcbc974d6b8af027c2769f9f63357b07` All heads unchanged: **True** Dependency order: #11172 ## Individual merge previews - PR #11172: **clean** against current base; head `c5f43513fbc745807c08b1a0d3513b476ab8c16e`; changed paths: none reported ## Dependency relationships No declared PR dependencies were found in the target PR chain. ``` Hosted checks: ```text linux skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356578490 relinker-asan pass 2m31s https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577141 register-context (macos-15-intel, Debug) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577079 relinker (macos-latest, clang++, x86_64) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577358 register-context (ubuntu-latest, Debug) pass 33s https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577183 register-context (ubuntu-latest, Release) pass 29s https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577062 relinker (windows-latest, g++) pass 6m38s https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577186 labels pass 8s https://github.com/boykopovar/AnyPS5/actions/runs/41141412689/job/124358585825 library-portability pass 1m45s https://github.com/boykopovar/AnyPS5/actions/runs/41141416046/job/124356311224 conventions pass 19s https://github.com/boykopovar/AnyPS5/actions/runs/41141412567/job/124356304483 relinker (ubuntu-latest, g++) pass 4m15s https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577235 relinker (macos-latest, clang++) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577245 register-context (macos-15-intel, Release) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577203 write-watch (macos-15-intel) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577152 write-watch (macos-15) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577069 eligibility pass 10s https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356311738 report pass 1m0s https://github.com/boykopovar/AnyPS5/actions/runs/41141415992/job/124356313581 windows pass 7m34s https://github.com/boykopovar/AnyPS5/actions/runs/41141416084/job/124356577045 ``` </details> ## Findings ### Blocking `WideCodecvtLength` returns the number of decoded wide characters and leaves the caller's state unchanged by using a local copy. The new test locks in that behavior. The author’s latest comment acknowledges that the character-count behavior is unverified on the console, while the exact-head implementation and tests still assert it. This remains an unmeasured target-specific assertion, and it differs from the standard `codecvt::do_length` contract. Please either provide pinned binary/console evidence for the target's return value and state behavior and test those results, or leave this slot throwing and record the unresolved behavior until it is verified, as the repository requires for unknown behavior. ### Non-blocking The debt entry exceeds the convention's 1,000-character guidance and the checker asks that it lead with the unresolved gap. This is a warning, not a check failure. ## Sources - [Repository rule for unknown behavior at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/c5f43513fbc745807c08b1a0d3513b476ab8c16e/AGENTS.md) - [Wide `length` implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/c5f43513fbc745807c08b1a0d3513b476ab8c16e/core/libs/prx/libc/src/LocaleSupport.cpp) - [Assertions that pin the returned character count](https://github.com/boykopovar/AnyPS5/blob/c5f43513fbc745807c08b1a0d3513b476ab8c16e/core/libs/tests/GuestLocale.cpp) - [Debt entry documenting the unverified console behavior](https://github.com/boykopovar/AnyPS5/blob/c5f43513fbc745807c08b1a0d3513b476ab8c16e/docs/dev/debt/libc.md) - [C++ draft `codecvt::do_length`, pinned to commit `d4d6f38143c1b495aa33b2e5de0e0ec2daa173ca`](https://github.com/cplusplus/draft/blob/d4d6f38143c1b495aa33b2e5de0e0ec2daa173ca/source/text.tex#L2330-L2358) ## Not verified I did not build or run C++ tests locally or test on a PS5. The six focused suite results and ASan run are author-reported; the current hosted macOS jobs were still pending when checked. ## To get this to a good state Please verify `length` against the pinned target binary or console, or keep this slot unsupported until its behavior is known. I will rerun the relevant checks against the new head.
XairRrR commented 2026-11-02 20:25:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T20:25:43Z.

Review: APPROVED


Re-checked — approved

Since fdc62fb104, the length slot throws instead of returning an unverified character count, the debt entry records that gap, and the checklist now reads Depends on: none. The merged tree builds, the six locale suites pass, and guest_locale still fails against main's LocaleSupport.cpp.

What changed since my last review

  • 597258ffad: WideCodecvtLength now only throws (codecvt<wchar_t,char>::length: console behavior unverified). The test no longer expects 2/3 for Aé€; it now requires the slot to throw.
  • 6d06d26606: the debt entry leads with the length gap, names PPSA03446's libc.prx as the source of the layout and of the _Mbtowcx/_Wctombx delegation, and notes that offset-to-top and typeinfo stay zero.
  • Two merge commits from main resolve conflicts in docs/dev/debt/libc.md and LocaleSupport.cpp. The in/out/unshift code and its tests are unchanged.
  • Description: Depends on: none (previously #10165), and a new Windows rerun by maskym on d7562dcc1d (guest_locale passed 3 runs; author-reported).
  • Discussion: MarcZX10 asked for length to throw until it is measured, which is now done. oneandonlydean then asked for the RequireException on length to be removed from the test; that has not been done (see below).

What I ran

Head d7562dcc1d873ad19809c9b31d350de94db517c9 merged with --no-ff into main 096c45570f516de76a43bbe1b97781381c84f55f (merged tree 4d8e99a644e1bb9ff664b93f011e943a152cd705). Debian 13 VM, GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.

git diff --check 096c45570f516de76a43bbe1b97781381c84f55f...d7562dcc1d873ad19809c9b31d350de94db517c9
python3 tools/check_conventions.py --base 096c45570f516de76a43bbe1b97781381c84f55f
ctest --test-dir build -R '^(guest_locale|guest_multibyte_locale|guest_wide_formatting|guest_wide_strings|guest_wide_conversion|guest_wide_stream_scan)$' --output-on-failure
# negative control
git show 096c45570f516de76a43bbe1b97781381c84f55f:core/libs/prx/libc/src/LocaleSupport.cpp > core/libs/prx/libc/src/LocaleSupport.cpp
ninja -C build guest_locale_tests
ctest --test-dir build -R '^guest_locale$' --output-on-failure
git show 4d8e99a644e1bb9ff664b93f011e943a152cd705:core/libs/prx/libc/src/LocaleSupport.cpp > core/libs/prx/libc/src/LocaleSupport.cpp
ninja -C build guest_locale_tests
ctest --test-dir build -R '^guest_locale$'
git status --porcelain
Check Result
git diff --check No output
check_conventions.py All conventions checks passed.
Build and libs (script) Passed
Selected tests (script, 3496) No new failures and no timeouts. The 9 known failures also fail on main (none are locale tests)
Six locale suites 6/6 passed
Negative control guest_locale aborts with main's LocaleSupport.cpp and passes again with the merged file restored. The worktree is clean afterwards
ctest, negative control
0% tests passed, 1 tests failed out of 1
The following tests FAILED:
	797 - guest_locale (Subprocess aborted)

Previous findings

  • length returns a character count: Resolved. WideCodecvtLength now throws. The debt entry states that the return value and state effect are unverified and that the standard do_length consumes input bytes. This also answers MarcZX10's blocking item on c5f43513fb.
  • Depends on: #10165: Resolved. The checklist now reads none, and the description keeps the textual rebase note. The PR merges and passes on current main without #10165.
  • _Mbtowcx throws on incomplete or invalid input: Still open, non-blocking. LocaleSupport.cpp:932-937 still throws on the -1 and -2 results. GuestLocale.cpp:243-252 still asserts those throws. The debt entry says in/out delegate to _Mbtowcx/_Wctombx on the console, which suggests the console returns codes there, but it does not list the throwing paths. Suggested fix: add the throws to the debt entry, or return the console's codes once they are confirmed. This can be a follow-up.

New findings

Blocking

None.

Non-blocking

  • The test requires the unimplemented length slot to throw. At GuestLocale.cpp:92, RequireException([&] { vtable->length(...); }) is still present at this head, although oneandonlydean asked on 597258ffad for it to be removed. Whoever later implements length would have to delete it. I agree with their request: drop that line and keep the positive in/out/unshift checks and the state checks. This is not blocking because no written rule in CONTRIBUTING.md or AGENTS.md forbids it.

Not verified

  • Console behaviour of the slot order, max_length 6, the partial/error mapping and length. I have no PPSA03446 libc.prx disassembly.
  • Windows (16-bit wchar_t) and ASan runs. Both are author- or contributor-reported only (maskym's Windows rerun on d7562dcc1d; the author's ASan run on an earlier head).
  • Validation-layer comparison: not applicable, because the change touches no AGC driver, shader recompiler or VideoOut file.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5742846694 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11172#pullrequestreview-5742846694). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-02T20:25:43Z. **Review:** APPROVED --- # Re-checked — approved Since `fdc62fb104`, the `length` slot throws instead of returning an unverified character count, the debt entry records that gap, and the checklist now reads `Depends on: none`. The merged tree builds, the six locale suites pass, and `guest_locale` still fails against `main`'s `LocaleSupport.cpp`. ## What changed since my last review - `597258ffad`: `WideCodecvtLength` now only throws (`codecvt<wchar_t,char>::length: console behavior unverified`). The test no longer expects `2`/`3` for `Aé€`; it now requires the slot to throw. - `6d06d26606`: the debt entry leads with the `length` gap, names PPSA03446's `libc.prx` as the source of the layout and of the `_Mbtowcx`/`_Wctombx` delegation, and notes that offset-to-top and typeinfo stay zero. - Two merge commits from `main` resolve conflicts in `docs/dev/debt/libc.md` and `LocaleSupport.cpp`. The `in`/`out`/`unshift` code and its tests are unchanged. - Description: `Depends on: none` (previously #10165), and a new Windows rerun by maskym on `d7562dcc1d` (`guest_locale` passed 3 runs; author-reported). - Discussion: MarcZX10 asked for `length` to throw until it is measured, which is now done. oneandonlydean then asked for the `RequireException` on `length` to be removed from the test; that has not been done (see below). ## What I ran Head `d7562dcc1d873ad19809c9b31d350de94db517c9` merged with `--no-ff` into `main` `096c45570f516de76a43bbe1b97781381c84f55f` (merged tree `4d8e99a644e1bb9ff664b93f011e943a152cd705`). Debian 13 VM, GCC 14.2.0, Release, Ninja, `BUILD_TESTING=ON`. ```sh git diff --check 096c45570f516de76a43bbe1b97781381c84f55f...d7562dcc1d873ad19809c9b31d350de94db517c9 python3 tools/check_conventions.py --base 096c45570f516de76a43bbe1b97781381c84f55f ctest --test-dir build -R '^(guest_locale|guest_multibyte_locale|guest_wide_formatting|guest_wide_strings|guest_wide_conversion|guest_wide_stream_scan)$' --output-on-failure # negative control git show 096c45570f516de76a43bbe1b97781381c84f55f:core/libs/prx/libc/src/LocaleSupport.cpp > core/libs/prx/libc/src/LocaleSupport.cpp ninja -C build guest_locale_tests ctest --test-dir build -R '^guest_locale$' --output-on-failure git show 4d8e99a644e1bb9ff664b93f011e943a152cd705:core/libs/prx/libc/src/LocaleSupport.cpp > core/libs/prx/libc/src/LocaleSupport.cpp ninja -C build guest_locale_tests ctest --test-dir build -R '^guest_locale$' git status --porcelain ``` | Check | Result | |---|---| | `git diff --check` | No output | | `check_conventions.py` | `All conventions checks passed.` | | Build and `libs` (script) | Passed | | Selected tests (script, 3496) | No new failures and no timeouts. The 9 known failures also fail on `main` (none are locale tests) | | Six locale suites | 6/6 passed | | Negative control | `guest_locale` aborts with `main`'s `LocaleSupport.cpp` and passes again with the merged file restored. The worktree is clean afterwards | <details><summary>ctest, negative control</summary> ```text 0% tests passed, 1 tests failed out of 1 The following tests FAILED: 797 - guest_locale (Subprocess aborted) ``` </details> ## Previous findings - **`length` returns a character count**: Resolved. [`WideCodecvtLength`](https://github.com/boykopovar/AnyPS5/blob/d7562dcc1d873ad19809c9b31d350de94db517c9/core/libs/prx/libc/src/LocaleSupport.cpp#L363-L365) now throws. The debt entry states that the return value and state effect are unverified and that the standard `do_length` consumes input bytes. This also answers MarcZX10's blocking item on `c5f43513fb`. - **Depends on: #10165**: Resolved. The checklist now reads `none`, and the description keeps the textual rebase note. The PR merges and passes on current `main` without #10165. - **`_Mbtowcx` throws on incomplete or invalid input**: Still open, non-blocking. [`LocaleSupport.cpp:932-937`](https://github.com/boykopovar/AnyPS5/blob/d7562dcc1d873ad19809c9b31d350de94db517c9/core/libs/prx/libc/src/LocaleSupport.cpp#L932-L937) still throws on the -1 and -2 results. [`GuestLocale.cpp:243-252`](https://github.com/boykopovar/AnyPS5/blob/d7562dcc1d873ad19809c9b31d350de94db517c9/core/libs/tests/GuestLocale.cpp#L243-L252) still asserts those throws. The debt entry says `in`/`out` delegate to `_Mbtowcx`/`_Wctombx` on the console, which suggests the console returns codes there, but it does not list the throwing paths. Suggested fix: add the throws to the debt entry, or return the console's codes once they are confirmed. This can be a follow-up. ## New findings ### Blocking None. ### Non-blocking - **The test requires the unimplemented `length` slot to throw.** At [`GuestLocale.cpp:92`](https://github.com/boykopovar/AnyPS5/blob/d7562dcc1d873ad19809c9b31d350de94db517c9/core/libs/tests/GuestLocale.cpp#L92), `RequireException([&] { vtable->length(...); })` is still present at this head, although oneandonlydean asked on `597258ffad` for it to be removed. Whoever later implements `length` would have to delete it. I agree with their request: drop that line and keep the positive `in`/`out`/`unshift` checks and the state checks. This is not blocking because no written rule in CONTRIBUTING.md or AGENTS.md forbids it. ## Not verified - Console behaviour of the slot order, `max_length` 6, the `partial`/`error` mapping and `length`. I have no PPSA03446 `libc.prx` disassembly. - Windows (16-bit `wchar_t`) and ASan runs. Both are author- or contributor-reported only (maskym's Windows rerun on `d7562dcc1d`; the author's ASan run on an earlier head). - Validation-layer comparison: not applicable, because the change touches no AGC driver, shader recompiler or VideoOut file. <!-- anyps5-bots job=1911 head=d7562dcc1d873ad19809c9b31d350de94db517c9 -->
MarcZX10 commented 2026-11-14 07:51:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T07:51:52Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: make the wide codecvt state reset safe for the guest state object.

What I ran

Inspected the prepared diff and changed source at head d7562dcc1d873ad19809c9b31d350de94db517c9, plus the UTF-8 helper and GuestLocale vtable definitions through repo_read.py. No build or tests were run during this review; the test results in the PR description are author-reported.

Results

Check Result Note
Source review failed State reset writes beyond its declared object
Build and tests not run Author-reported checks were not rerun
Console behavior not run No PS5 run was reported

Findings

Blocking

  • core/libs/prx/libc/src/LocaleSupport.cpp:359 clears 16 bytes through the state pointer passed to unshift. The codecvt vtable contract declares this state as std::uint64_t*, while the changed thread-local buffers in this file are 16 bytes; callers can also pass an ordinary mbstate_t object. The implementation therefore writes beyond a state object when it is smaller than 16 bytes, corrupting adjacent memory. Reset only the state size guaranteed by the actual guest ABI, or use a correctly sized guest state object consistently.

Non-blocking

None.

Not verified

No build, tests, or PS5 execution were performed. The reported Linux and earlier Windows test runs are author-supplied. Reviewed all three changed files: core/libs/prx/libc/src/LocaleSupport.cpp, core/libs/tests/GuestLocale.cpp, and docs/dev/debt/libc.md; none were excluded.

To get this to a good state

Correct the unshift state reset and rerun the relevant guest locale and wide conversion checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5902860732 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11172#pullrequestreview-5902860732). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T07:51:52Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: make the wide codecvt state reset safe for the guest state object. ## What I ran Inspected the prepared diff and changed source at head `d7562dcc1d873ad19809c9b31d350de94db517c9`, plus the UTF-8 helper and `GuestLocale` vtable definitions through `repo_read.py`. No build or tests were run during this review; the test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | State reset writes beyond its declared object | | Build and tests | not run | Author-reported checks were not rerun | | Console behavior | not run | No PS5 run was reported | ## Findings ### Blocking - `core/libs/prx/libc/src/LocaleSupport.cpp:359` clears 16 bytes through the `state` pointer passed to `unshift`. The codecvt vtable contract declares this state as `std::uint64_t*`, while the changed thread-local buffers in this file are 16 bytes; callers can also pass an ordinary `mbstate_t` object. The implementation therefore writes beyond a state object when it is smaller than 16 bytes, corrupting adjacent memory. Reset only the state size guaranteed by the actual guest ABI, or use a correctly sized guest state object consistently. ### Non-blocking None. ## Not verified No build, tests, or PS5 execution were performed. The reported Linux and earlier Windows test runs are author-supplied. Reviewed all three changed files: `core/libs/prx/libc/src/LocaleSupport.cpp`, `core/libs/tests/GuestLocale.cpp`, and `docs/dev/debt/libc.md`; none were excluded. ## To get this to a good state Correct the `unshift` state reset and rerun the relevant guest locale and wide conversion checks on the updated head.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11172
No description provided.