feat(libSceIcu): implement UTF-8 and UTF-16 conversion #10965

Merged
AZLisme merged 6 commits from upstream-pr/10965 into main 2026-11-17 10:42:15 +00:00
AZLisme commented 2026-10-25 11:22:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AZLisme on 2026-10-25T11:22:18Z.


What

New preserving rebase: c2076fe30ee3442546af395930defd74b7bfac2a is based on frozen main 6e9b9134f6ed14e659d870a33118d164096551df, which contains the actual #11760 merge 1dcfe038754ae612ac90cd8ee954deffec1938c4. All 112 inherited sceIcuUnknown_*_nid_no_patch exports continue to throw, and their unverified-prototype debt is retained. The complete upstream ICU implementations, declarations, test registrations and debt are preserved; conflict resolution adds this topic’s debt without replacing the upstream entries. Owned UTF conversions, guarded guest outputs and aliased-output error ordering implementation, declaration and fixture bytes are unchanged from previously published b0a817eaa977c38ca24c0253a290bc0f383ebe7e. This branch carries only its own topic over main. The actual predecessor #10964 remains required; retain #10961→#10962→#10963→#10964→#10965→#10966→#10967→#11088.

Earlier preserving rebase: b0a817eaa977c38ca24c0253a290bc0f383ebe7e on frozen main aebeaa53f54dd4eccfe313f147807e3434588404 includes the actual #10961 merge 2ab073a1e7889d009edaabd84ab8cb10ce829156 and the earlier merged #11013 helpers. All owned implementation, declaration and fixture bytes are unchanged from published 4e4a4a132be9d7f10803ad462c09803cdeee5f84. Shared CMake and umbrella files preserve the inherited unescape source/test/header and this topic. Main debt entries and the existing conversion gaps are retained; the sole documentation follow-up removes an obsolete sentence that called other exports unimplemented after unescape landed. The immediate predecessor #10964 remains pending; retain #10961→#10962→#10963→#10964→#10965→#10966→#10967→#11088.

Implement u_strFromUTF8, u_strToUTF8, u_strFromUTF8WithSub, u_strToUTF8WithSub and u_strFromUTF8Lenient. Preserve strict validation, maximal-subpart substitutions and counts, complete UTF-8 output prefixes, lenient malformed-byte behavior, preflight lengths, error/warning propagation and buffer termination.

Contracts follow pinned ICU 78.1 ustrtrns.cpp, utf_impl.cpp and termination helpers. Names and NIDs match the pinned PS5 3.20 inventory. The console ICU version and full behavior equivalence remain unverified; the bounded firmware 13.42 native-code comparison below covers two exports. Invalid-input and size limits remain in debt. No new dependency is added.

Checked GuestArena::HostWrite scopes now cover every destination unit and terminator plus optional length/substitution outputs and error status. Required scopes open before the first output mutation. Termination rechecks the resulting error after storing the length, matching ICU’s success gate when length or substitution output aliases the error. A refused scope throws through the existing unsupported path before any output changes. Latched errors, invalid-argument no-read paths, lenient capacity rejection, zero-capacity preflight and scalar alias ordering are preserved.

Typed declarations are reachable through libSceIcu.hpp; source and tests use those canonical declarations. The earlier preserving rebase is 4e4a4a132be9d7f10803ad462c09803cdeee5f84 on approved main 6733079b2d01bb25aa1e6e771680da6a17363e3b, which contains the actual #11013 merge bd1b31548c4f8a21de87b3856b881083ca80492a. The landed invariant/version source, headers, fixture and debt are retained. Conversion implementation/header and both complete conversion/memory fixtures are byte-identical to 58c283d6890d6faaeeb1ec5bd5fd17908ee1093b. Shared CMake and umbrella changes are additive; the final debt sentence now excludes the implemented invariant/version helpers from the remaining unimplemented exports. Keep the declared predecessor #10964 and the existing ICU landing order.

Tested

2026-11-01 Windows CI FAILED: run 41295117649, 30303a5743bc7bed9db89efe8602eae904c0516d + main 26fa1212b82f76dd49cf12d65e445d6ff3e0844c: 1,679 passed, 904 skipped, one failed. guest_avplayer alone failed: no-sync video lead was 33 ms versus the required 100 ms within 500 ms. All ten ICU cases, including both new conversion/memory fixtures, passed. The same AvPlayer case passed in five other main-26fa jobs; this does not establish a flake or an ICU cause. Please arrange a collaborator rerun or matched-baseline check before merge; keep the failure and thresholds intact. General full-suite, skip-audit and header CTests were not run.

2026-11-01: preserving rebase 30303a5743bc7bed9db89efe8602eae904c0516d onto fixed main 26fa1212b82f76dd49cf12d65e445d6ff3e0844c. Linux GCC 16.2.1 Release: baseline 61 plain + 4 logging-enabled runtime CTests; private SIG-plus-six-ICU union 4908848dab02fb1f0a9fad7e9525ddb8a628177a 71 + 6. All passed, with 65 public-header tests per side. Relevant: guest_icu_utf_conversions, guest_icu_utf_memory. Scope is this fixed baseline/private composition; bare heads, later main, Windows, native ABI and unloading remain unqualified. Earlier results retain their original scope.

2026-10-30 fresh Linux integration check on fixed main 0362b1521c4ee08eeeccc2f98e9987e36fca9ea1: a separate private candidate 8a5c8c499f0e0a157bd110430c1d99ee73bb0d47 (tree 620649fa8b0512d9c7e114c670342a691fd1433a) combines #10953 at 581d45c282371af828efec2a8cec6f43beacc68a with the same six unchanged published ICU heads recorded in the earlier converter-callback integration update. No public branch was rebased by this check.

Fresh native Linux x86-64 Release builds passed 53/53 selected plain runtime CTests on that main baseline and 63/63 on the private candidate. With ANYPS5_LOG_FILE set before process startup, another 4/4 baseline and 6/6 candidate runtime executions passed. Together these are 126 runtime CTest executions; both lanes also passed 65/65 public-header checks, 130 header executions total, with zero failed, skipped or Not Run rows. The candidate ran all 13 registered ICU fixtures, including both guest-memory protection fixtures; converter callbacks ran in both lanes. The selected integration set also exercises logging, heap/allocator, signal, exception and thread behavior.

Production NID patching and readelf/nm inspection found the baseline’s four converter-callback NIDs and all 39 targeted candidate NIDs; this is artifact evidence, not patched-loader functional coverage. Twelve separately observed controlled std::abort child runs returned the expected exit 3; they are not additional CTests or proof of native signal-context behavior. Source and dependency identities were checked before and after execution.

These results apply only to the fixed baseline and private SIG-plus-six-ICU candidate. They add no bare-public-head, later-main, Windows, native-ABI, full-suite, GPU or unload qualification. Earlier results keep their original inputs and scope. The existing predecessor, preserving-rebase, maintainer CI and review requirements and agreed ICU landing order still apply.

2026-10-30 converter-callback integration update: #12692 actually merged as 91a69952c100 (topic 207ac4b5ecfe). Against pinned main 08a10d225306ad102b57408e2ef7566bcfb829b2, all six published ICU heads remain independently clean to integrate; this source review found no duplicate implementation, new dependency or individually required rebase. A separate private all-six union, 6e174798251592474dd94c61975655b409b9c2e9 (tree 446a6e346d3c6fac2e19e358d4376376778c7ae9), preserves 35 owned helpers, the four landed converter callbacks and 13 source-registered ICU fixtures through routine shared-file resolutions; the 98 unknown stubs remain unchanged.

Exact published inputs: #10962 bbccec1140eeccb5adf61f7c497791b183c1bf93, #10963 28cc96f3be1e16d2e3f098b0ae5b77b4fea85e09, #10964 4360e8f85b0bbd184199d9a3822dc30a8bd5f81e, #10965 c2076fe30ee3442546af395930defd74b7bfac2a, #10966 491e27444d83b53bc215a94edf132aee6a4707d7, #10967 babf2bc72012bd926f35408b3d602d162a5ecd1b.

Fresh native Linux x86-64 Release, GCC 16.2.1: the pinned08a main baseline passed 18/18 selected runtime cases and 65/65 public-header checks; the exact private all-six union passed 26/26 runtime cases and 65/65 headers, with zero failures, skips or Not Run rows. The union executed all 13 ICU fixtures, including guest_icu_copy_guest_memory and guest_icu_utf_memory, alongside 13 heap/allocator cases; the converter-callback fixture passed in both lanes. Production NID patching plus readelf/nm inspection verified the four callback NIDs in the baseline and all 39 targeted NIDs in the union (35 owned helpers plus four callbacks). This last check is artifact inspection, not patched-module loader runtime or native-ABI proof.

These results cover only that fixed baseline and private all-six union, not any bare published head, later main, Windows/native ABI, all-nine integration, full suite, title or GPU behavior. Earlier main750 and other historical results retain their original inputs and scope. The declared order remains #10962, #10963, #10964, #10965, #10966, #10967, then #11088; the already merged #12692 adds no new prerequisite. Actual #10964 merge must come first, followed by a preserving rebase, fresh integration checks and re-review before this PR lands.

Current exact-head native Windows validation: run 40621182257, attempt 1 tested c2076fe30ee3442546af395930defd74b7bfac2a independently on its frozen main 6e9b9134f6ed14e659d870a33118d164096551df. Windows x86-64, GitHub-hosted win25-vs2026 image 20261021.278.1 (OS build 10.0.26100.33650), verified WinLibs GCC 15.2.0 r7/UCRT, normal-root Release, BUILD_TESTING=ON. guest_icu_version, guest_icu_unescape, guest_icu_utf_conversions, guest_icu_utf_memory passed 4/4, and all 65/65 normal public-header CTests passed once, with zero failures or skipped cases. Each lane used a separate fresh build without object or compiler-cache reuse. The separate bare-main control passed its two existing ICU fixtures and 65 header checks.

The unchanged UTF-memory fixture executed its Windows RejectedWrites destination, scalar and status rejection checks, including unchanged outputs. Native preprocessing retained _WIN32 and the original aborting Require checks under Release; no fixture or product source was changed. Complete recursive source/submodule identity was checked before and after execution. Actual executable/provider payloads, PE imports, compile commands and raw CTest logs are archived with the run. Provider resolution is inferred from the normal import chain and absolute command/PATH staging; no loaded-module trace was captured.

This is focused standalone Windows component/header evidence. macOS, physical PS5, sanitizer, full-product CI and later-main integration are not covered by this run. The existing review, applicable full maintainer CI and agreed actual-predecessor/landing-order gates remain.

Current exact-head validation: c2076fe30ee3442546af395930defd74b7bfac2a on frozen main 6e9b9134f6ed14e659d870a33118d164096551df: Linux x86-64, normal-root Release, BUILD_TESTING=ON. guest_icu_version, guest_icu_unescape, guest_icu_utf_conversions, guest_icu_utf_memory passed 4/4; all 65/65 normal public-header CTests passed, with no failed or skipped CTest cases. The complete ICU provider and registered fixtures were built for this standalone branch. The common core was freshly built from this main once; this lane retained 190 objects only after matching their exact compiler commands, complete observed input hashes and object digests, and rebuilt or added 8 objects. Source identity before/after testing and the actual fixture/provider paths were verified. Conventions, whitespace and source-preservation checks pass.

The Windows-only RejectedWrites destination/scalar/status rejection subcases were not executed on Linux.

Contributor Windows report: ycbuzi reports head c2076fe30ee3442546af395930defd74b7bfac2a merged with main 200f40814dd6041072b089e6ae05edb42d2a8d52 on Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. The named test executables built successfully, and guest_icu_utf_conversions, guest_icu_utf_memory, guest_icu_version, guest_icu_unescape passed both repetitions of ctest --repeat until-fail:2. This is a contributor report; raw logs were not independently reviewed.

Our Linux execution, the contributor’s Windows report and the automatic upstream Windows compile/link checks retain their recorded source and validation scopes. Actual predecessor #10964 merge, applicable full maintainer CI and review remain required.

All results below are historical and retain their stated head, base, platform and provenance. Earlier uses of “current”, “fresh”, “now” or “this rebased head” within those retained source-bound entries refer to the named historical revision. They supply no new-head Windows, macOS, physical-PS5, sanitizer, full-product or private-composition runtime credit. Existing actual-predecessor, integration, review and applicable full-CI gates remain.

Earlier validation: documentation-only head b0a817eaa977c38ca24c0253a290bc0f383ebe7e follows runtime-tested eccc0082eac15184908890b1032e829b2431d491 on frozen main aebeaa53f54dd4eccfe313f147807e3434588404. Its only change removes the stale debt sentence. The complete product, CMake, test and dependency trees and every recorded compiler input are identical; the actual binaries and objects were reverified unchanged. Tests were not rerun for this documentation commit.

On eccc0082eac15184908890b1032e829b2431d491, fresh normal-root Linux Release core/module/fixture builds compiled 197 objects with compiler caching disabled and no copied prior core/module/test binaries. Registered guest_icu_version, guest_icu_unescape, guest_icu_utf_conversions and guest_icu_utf_memory passed 4/4; all 65/65 actual public-header CTests passed, with zero skips or failures. The audit reports 368 libraries and 12,814 exports. Provider linkage resolves only this fresh build’s ICU/libc/kernel PRXs. These results qualify the documentation head through the explicit code-equivalence checks.

Conventions against the pinned origin/main and whitespace pass. Existing pinned dependency sources and source-built FFmpeg configuration package were verified separately. This is independent Linux component/header evidence, with no new Windows, macOS, PS5, sanitizer, full-product or later-main execution claim. Earlier evidence below retains its named historical scope. The declared predecessor and agreed landing order remain required.

Earlier preserving rebase 4e4a4a132be9d7f10803ad462c09803cdeee5f84 on 6733079b2d01bb25aa1e6e771680da6a17363e3b: source-preservation checks pass. All four owned production/header/fixture files and all six non-shared upstream source/header/fixture files retain their original bytes. The CMake registration, umbrella includes and both debt entries form the checked additive union. git diff --check, source conventions and the Python public-header audit pass; the audit reports 368 libraries and 12,266 unique exports with reachable declarations. This is a static audit, not header compilation.

Earlier fresh exact-head validation for 4e4a4a132be9d7f10803ad462c09803cdeee5f84 on frozen base 6733079b2d01bb25aa1e6e771680da6a17363e3b: Linux x86-64, GNU 16.2.1, Release, BUILD_TESTING=ON. The complete ICU module and every registered fixture were freshly built through the actual library CMake and original root helper bodies. guest_icu_version, guest_icu_utf_conversions, guest_icu_utf_memory passed 3/3, with zero failures or skips; this includes the inherited #11013 version test and every owned topic fixture. All five C++ header units passed, covering standalone/repeated inclusion, the umbrella and composition with libc/kernel. The passing declaration audit is reused from the source owner’s exact-head receipt; C++ header compilation is fresh.

The common libc/kernel runtime was freshly built once from that approved base and reused for this independent provider only after all 258 actual core project inputs, normal CMake/helper bodies, copied artifact hashes and provider paths were qualified against this head. Pinned source-built ZArchive/zstd archives were reused after source/hash/pin checks. This validates this independent ICU provider; it is not a seven-topic composite or a fresh core rebuild per branch.

Earlier validation is Linux component evidence. No new native Windows, macOS, PS5, sanitizer, full-product or GPU result is claimed; Windows-only HostWrite-refusal paths were not executed by this Linux lane. Earlier platform, maintainer CI, firmware and private-integration evidence below retains its original head/base scope and does not qualify this rebased head.

Historical evidence below retains its original source and platform scope. The author and reviewer results concern old head 58c283d6890d6faaeeb1ec5bd5fd17908ee1093b or the explicitly named earlier head/base; the complete unchanged fixture bodies, including the 556 scalar-alias cases and guarded guest-memory/no-write paths, are preserved by the rebase.

Linux x86-64, GCC 16.2.1, Release, BUILD_TESTING=ON, on main 3a2c51afd2ee6a824cd3a294912c65e6bbf2b768. Built the complete ICU module through its production CMake and ran guest_icu_utf_conversions and guest_icu_utf_memory: 2/2 passed. Reused libc/kernel artifacts only after checking their 270-file Linux source/header dependency closure and artifact hashes against this base.

Coverage includes every Unicode scalar and existing malformed/capacity/error cases, real shared guest mappings and aliases, cross-page buffers, optional output scalars, terminator-only writes and read-only no-write paths. The updated mapping fixture adds 556 scalar-alias cases across all five exports: length/error, substitution/error, length/substitution and three-way aliases; positive and zero outputs; warnings and latched failures; short/exact/extra/zero capacity, null preflight and empty conversions. It checks every destination unit and terminator canary. The lenient known-length rejection still writes length then overflow without reading the source or destination.

Negative control: rebuilding the unchanged c9e83c9c694705c45edd248a2b9e530e75e12a76 conversion source as the complete ICU module against the updated mapped fixture fails the new aliased-terminator canary assertion. The fixed module passes it. Public-header audit passed (368 libraries, 12,197 exports); three focused header/composition units, conventions and whitespace checks passed for 58c283d6890d6faaeeb1ec5bd5fd17908ee1093b.

A separate local composition of pinned #11013 plus #10961–#10967, using this updated conversion head, passes all 10 focused runtime tests, has 42 distinct public NIDs, and passes 11 header composition units including all 368 public umbrellas together. Every original production/test body and test registration remains present. This validates the local union; keep the declared integration predecessor #10964 and reconcile shared source-list, umbrella and debt files when rebasing.

Historical native Windows review applies to the earlier head c9e83c9c694705c45edd248a2b9e530e75e12a76, tested on Windows 11, WinLibs GCC 15.2.0 r7, Release, merged into main e05ba6feeb. It reported repeated success including Windows read-only RejectedWrites cases. Later maintainer CI for old head 58c283d6890d6faaeeb1ec5bd5fd17908ee1093b is qualified separately below. Neither historical scope validates the preserving rebased head; macOS library runtime and physical-console execution remain unverified.

Independent exact-head Linux re-review by ahmadmuj validates 58c283d689 merged onto main 2e1c72239b. The actual ICU module and both focused tests passed three repeats. The reviewer reports 75,954,840 aliased-output comparisons and about 642 million non-aliased calls against ICU 74.2 with zero mismatches, plus clean source ASan/UBSan runs; the prior-source control fails the new terminator-canary case. These are reviewer-reported Linux results, separate from author-run checks, historical Windows reports and hosted CI.

Independent firmware 13.42 native-code comparison by BunnyFl covers only u_strFromUTF8 and u_strToUTF8. The reviewer ran the firmware module's code on a PC against UtfConversions.cpp from 58c283d6890d6faaeeb1ec5bd5fd17908ee1093b, compiled unchanged with an always-open, no-op GuestArena::HostWrite stand-in. The reported 400,000-call corpus, repeated three times, plus 2 million calls with two other seeds produced zero mismatches in return values, status, optional length output and all 512 destination bytes. Inputs include malformed UTF-8/UTF-16, explicit and NUL-terminated lengths, preflight/short/exact/extra/negative capacities, incoming warnings/errors, termination and partial surrogate output; targeted mutations were detected. This is reviewer-reported firmware code execution on a PC, not physical-console, full-library ABI, native Windows integration or guest-write validation. Null status pointers, null source pointers with nonzero length, read-only/watched mappings and scalar-output aliases are not established by this report. The reviewer found no firmware 13.42 exports named u_strFromUTF8WithSub, u_strToUTF8WithSub or u_strFromUTF8Lenient, including _50–_89 suffixes; those three retain their source-backed and separate Linux differential evidence.

Historical maintainer CI run 40293533207 selects old head 58c283d6890d6faaeeb1ec5bd5fd17908ee1093b merged on b27cc8416f820e40ce187f165d34138e24373dd7. Attempt 1 failed overall because four unchanged compiler-mode cases timed out in the Windows job; the focused UTF conversion/memory tests and headers passed. Attempt 2 succeeded: the fresh Windows job 121523996111 executed 1,639 passes and 810 policy-accepted skips out of 2,449 registered tests, including both UTF fixtures, 65 header cases and all four earlier timeout cases. Linux shown under attempt-2 API job 121523999013 is carried forward from the original attempt-1 execution 121474009987, with 2,255 passes and 91 policy-accepted skips out of 2,346. Its original 08:51–09:35 execution precedes the 10:35 retry; no new Linux execution occurred. The retry does not diagnose the original timeout cause, erase the original failure or qualify the rebased head.

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: #10964
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5004254272 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10965). Originally posted by [AZLisme](https://github.com/AZLisme) on 2026-10-25T11:22:18Z. --- ### What **New preserving rebase:** `c2076fe30ee3442546af395930defd74b7bfac2a` is based on frozen main `6e9b9134f6ed14e659d870a33118d164096551df`, which contains the actual #11760 merge `1dcfe038754ae612ac90cd8ee954deffec1938c4`. All 112 inherited `sceIcuUnknown_*_nid_no_patch` exports continue to throw, and their unverified-prototype debt is retained. The complete upstream ICU implementations, declarations, test registrations and debt are preserved; conflict resolution adds this topic’s debt without replacing the upstream entries. Owned UTF conversions, guarded guest outputs and aliased-output error ordering implementation, declaration and fixture bytes are unchanged from previously published `b0a817eaa977c38ca24c0253a290bc0f383ebe7e`. This branch carries only its own topic over main. The actual predecessor #10964 remains required; retain #10961→#10962→#10963→#10964→#10965→#10966→#10967→#11088. **Earlier preserving rebase:** `b0a817eaa977c38ca24c0253a290bc0f383ebe7e` on frozen main `aebeaa53f54dd4eccfe313f147807e3434588404` includes the actual #10961 merge `2ab073a1e7889d009edaabd84ab8cb10ce829156` and the earlier merged #11013 helpers. All owned implementation, declaration and fixture bytes are unchanged from published `4e4a4a132be9d7f10803ad462c09803cdeee5f84`. Shared CMake and umbrella files preserve the inherited unescape source/test/header and this topic. Main debt entries and the existing conversion gaps are retained; the sole documentation follow-up removes an obsolete sentence that called other exports unimplemented after unescape landed. The immediate predecessor #10964 remains pending; retain #10961→#10962→#10963→#10964→#10965→#10966→#10967→#11088. Implement `u_strFromUTF8`, `u_strToUTF8`, `u_strFromUTF8WithSub`, `u_strToUTF8WithSub` and `u_strFromUTF8Lenient`. Preserve strict validation, maximal-subpart substitutions and counts, complete UTF-8 output prefixes, lenient malformed-byte behavior, preflight lengths, error/warning propagation and buffer termination. Contracts follow pinned [ICU 78.1 ustrtrns.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/ustrtrns.cpp), [utf_impl.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/utf_impl.cpp) and [termination helpers](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/ustring.cpp). Names and NIDs match the pinned [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceIcu.c). The console ICU version and full behavior equivalence remain unverified; the bounded firmware 13.42 native-code comparison below covers two exports. Invalid-input and size limits remain in debt. No new dependency is added. Checked `GuestArena::HostWrite` scopes now cover every destination unit and terminator plus optional length/substitution outputs and error status. Required scopes open before the first output mutation. Termination rechecks the resulting error after storing the length, matching ICU’s success gate when length or substitution output aliases the error. A refused scope throws through the existing unsupported path before any output changes. Latched errors, invalid-argument no-read paths, lenient capacity rejection, zero-capacity preflight and scalar alias ordering are preserved. Typed declarations are reachable through `libSceIcu.hpp`; source and tests use those canonical declarations. The earlier preserving rebase is `4e4a4a132be9d7f10803ad462c09803cdeee5f84` on approved main `6733079b2d01bb25aa1e6e771680da6a17363e3b`, which contains the actual #11013 merge `bd1b31548c4f8a21de87b3856b881083ca80492a`. The landed invariant/version source, headers, fixture and debt are retained. Conversion implementation/header and both complete conversion/memory fixtures are byte-identical to `58c283d6890d6faaeeb1ec5bd5fd17908ee1093b`. Shared CMake and umbrella changes are additive; the final debt sentence now excludes the implemented invariant/version helpers from the remaining unimplemented exports. Keep the declared predecessor #10964 and the existing ICU landing order. ### Tested 2026-11-01 **Windows CI FAILED**: [run 41295117649](https://github.com/boykopovar/AnyPS5/actions/runs/41295117649), `30303a5743bc7bed9db89efe8602eae904c0516d` + main `26fa1212b82f76dd49cf12d65e445d6ff3e0844c`: 1,679 passed, 904 skipped, one failed. `guest_avplayer` alone failed: no-sync video lead was 33 ms versus the required 100 ms within 500 ms. All ten ICU cases, including both new conversion/memory fixtures, passed. The same AvPlayer case passed in five other main-26fa jobs; this does not establish a flake or an ICU cause. Please arrange a collaborator rerun or matched-baseline check before merge; keep the failure and thresholds intact. General full-suite, skip-audit and header CTests were not run. 2026-11-01: preserving rebase `30303a5743bc7bed9db89efe8602eae904c0516d` onto fixed main `26fa1212b82f76dd49cf12d65e445d6ff3e0844c`. Linux GCC 16.2.1 Release: baseline 61 plain + 4 logging-enabled runtime CTests; private SIG-plus-six-ICU union `4908848dab02fb1f0a9fad7e9525ddb8a628177a` 71 + 6. All passed, with 65 public-header tests per side. Relevant: `guest_icu_utf_conversions`, `guest_icu_utf_memory`. Scope is this fixed baseline/private composition; bare heads, later main, Windows, native ABI and unloading remain unqualified. Earlier results retain their original scope. 2026-10-30 fresh Linux integration check on fixed main `0362b1521c4ee08eeeccc2f98e9987e36fca9ea1`: a separate private candidate `8a5c8c499f0e0a157bd110430c1d99ee73bb0d47` (tree `620649fa8b0512d9c7e114c670342a691fd1433a`) combines #10953 at `581d45c282371af828efec2a8cec6f43beacc68a` with the same six unchanged published ICU heads recorded in the earlier converter-callback integration update. No public branch was rebased by this check. Fresh native Linux x86-64 Release builds passed 53/53 selected plain runtime CTests on that main baseline and 63/63 on the private candidate. With `ANYPS5_LOG_FILE` set before process startup, another 4/4 baseline and 6/6 candidate runtime executions passed. Together these are 126 runtime CTest executions; both lanes also passed 65/65 public-header checks, 130 header executions total, with zero failed, skipped or Not Run rows. The candidate ran all 13 registered ICU fixtures, including both guest-memory protection fixtures; converter callbacks ran in both lanes. The selected integration set also exercises logging, heap/allocator, signal, exception and thread behavior. Production NID patching and `readelf`/`nm` inspection found the baseline’s four converter-callback NIDs and all 39 targeted candidate NIDs; this is artifact evidence, not patched-loader functional coverage. Twelve separately observed controlled `std::abort` child runs returned the expected exit 3; they are not additional CTests or proof of native signal-context behavior. Source and dependency identities were checked before and after execution. These results apply only to the fixed baseline and private SIG-plus-six-ICU candidate. They add no bare-public-head, later-main, Windows, native-ABI, full-suite, GPU or unload qualification. Earlier results keep their original inputs and scope. The existing predecessor, preserving-rebase, maintainer CI and review requirements and agreed ICU landing order still apply. 2026-10-30 converter-callback integration update: #12692 actually merged as `91a69952c100` (topic `207ac4b5ecfe`). Against pinned main `08a10d225306ad102b57408e2ef7566bcfb829b2`, all six published ICU heads remain independently clean to integrate; this source review found no duplicate implementation, new dependency or individually required rebase. A separate private all-six union, `6e174798251592474dd94c61975655b409b9c2e9` (tree `446a6e346d3c6fac2e19e358d4376376778c7ae9`), preserves 35 owned helpers, the four landed converter callbacks and 13 source-registered ICU fixtures through routine shared-file resolutions; the 98 unknown stubs remain unchanged. Exact published inputs: #10962 `bbccec1140eeccb5adf61f7c497791b183c1bf93`, #10963 `28cc96f3be1e16d2e3f098b0ae5b77b4fea85e09`, #10964 `4360e8f85b0bbd184199d9a3822dc30a8bd5f81e`, #10965 `c2076fe30ee3442546af395930defd74b7bfac2a`, #10966 `491e27444d83b53bc215a94edf132aee6a4707d7`, #10967 `babf2bc72012bd926f35408b3d602d162a5ecd1b`. Fresh native Linux x86-64 Release, GCC 16.2.1: the pinned08a main baseline passed 18/18 selected runtime cases and 65/65 public-header checks; the exact private all-six union passed 26/26 runtime cases and 65/65 headers, with zero failures, skips or Not Run rows. The union executed all 13 ICU fixtures, including `guest_icu_copy_guest_memory` and `guest_icu_utf_memory`, alongside 13 heap/allocator cases; the converter-callback fixture passed in both lanes. Production NID patching plus `readelf`/`nm` inspection verified the four callback NIDs in the baseline and all 39 targeted NIDs in the union (35 owned helpers plus four callbacks). This last check is artifact inspection, not patched-module loader runtime or native-ABI proof. These results cover only that fixed baseline and private all-six union, not any bare published head, later main, Windows/native ABI, all-nine integration, full suite, title or GPU behavior. Earlier main750 and other historical results retain their original inputs and scope. The declared order remains #10962, #10963, #10964, #10965, #10966, #10967, then #11088; the already merged #12692 adds no new prerequisite. Actual #10964 merge must come first, followed by a preserving rebase, fresh integration checks and re-review before this PR lands. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> **Current exact-head native Windows validation:** [run 40621182257, attempt 1](https://github.com/AZLisme/AnyPS5/actions/runs/40621182257/job/122595338700) tested `c2076fe30ee3442546af395930defd74b7bfac2a` independently on its frozen main `6e9b9134f6ed14e659d870a33118d164096551df`. Windows x86-64, GitHub-hosted `win25-vs2026` image `20261021.278.1` (OS build `10.0.26100.33650`), verified WinLibs GCC 15.2.0 r7/UCRT, normal-root Release, `BUILD_TESTING=ON`. `guest_icu_version`, `guest_icu_unescape`, `guest_icu_utf_conversions`, `guest_icu_utf_memory` passed **4/4**, and all **65/65** normal public-header CTests passed once, with zero failures or skipped cases. Each lane used a separate fresh build without object or compiler-cache reuse. The separate bare-main control passed its two existing ICU fixtures and 65 header checks. The unchanged UTF-memory fixture executed its Windows `RejectedWrites` destination, scalar and status rejection checks, including unchanged outputs. Native preprocessing retained `_WIN32` and the original aborting `Require` checks under Release; no fixture or product source was changed. Complete recursive source/submodule identity was checked before and after execution. Actual executable/provider payloads, PE imports, compile commands and raw CTest logs are archived with the run. Provider resolution is inferred from the normal import chain and absolute command/PATH staging; no loaded-module trace was captured. This is focused standalone Windows component/header evidence. macOS, physical PS5, sanitizer, full-product CI and later-main integration are not covered by this run. The existing review, applicable full maintainer CI and agreed actual-predecessor/landing-order gates remain. **Current exact-head validation:** `c2076fe30ee3442546af395930defd74b7bfac2a` on frozen main `6e9b9134f6ed14e659d870a33118d164096551df`: Linux x86-64, normal-root Release, `BUILD_TESTING=ON`. `guest_icu_version`, `guest_icu_unescape`, `guest_icu_utf_conversions`, `guest_icu_utf_memory` passed **4/4**; all **65/65** normal public-header CTests passed, with no failed or skipped CTest cases. The complete ICU provider and registered fixtures were built for this standalone branch. The common core was freshly built from this main once; this lane retained 190 objects only after matching their exact compiler commands, complete observed input hashes and object digests, and rebuilt or added 8 objects. Source identity before/after testing and the actual fixture/provider paths were verified. Conventions, whitespace and source-preservation checks pass. The Windows-only RejectedWrites destination/scalar/status rejection subcases were not executed on Linux. **Contributor Windows report:** [ycbuzi](https://github.com/boykopovar/AnyPS5/pull/10965#issuecomment-6456727511) reports head `c2076fe30ee3442546af395930defd74b7bfac2a` merged with main `200f40814dd6041072b089e6ae05edb42d2a8d52` on Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, `BUILD_TESTING=ON`. The named test executables built successfully, and `guest_icu_utf_conversions`, `guest_icu_utf_memory`, `guest_icu_version`, `guest_icu_unescape` passed both repetitions of `ctest --repeat until-fail:2`. This is a contributor report; raw logs were not independently reviewed. Our Linux execution, the contributor’s Windows report and the automatic upstream Windows compile/link checks retain their recorded source and validation scopes. Actual predecessor #10964 merge, applicable full maintainer CI and review remain required. All results below are historical and retain their stated head, base, platform and provenance. Earlier uses of “current”, “fresh”, “now” or “this rebased head” within those retained source-bound entries refer to the named historical revision. They supply no new-head Windows, macOS, physical-PS5, sanitizer, full-product or private-composition runtime credit. Existing actual-predecessor, integration, review and applicable full-CI gates remain. **Earlier validation:** documentation-only head `b0a817eaa977c38ca24c0253a290bc0f383ebe7e` follows runtime-tested `eccc0082eac15184908890b1032e829b2431d491` on frozen main `aebeaa53f54dd4eccfe313f147807e3434588404`. Its only change removes the stale debt sentence. The complete product, CMake, test and dependency trees and every recorded compiler input are identical; the actual binaries and objects were reverified unchanged. Tests were not rerun for this documentation commit. On `eccc0082eac15184908890b1032e829b2431d491`, fresh normal-root Linux Release core/module/fixture builds compiled 197 objects with compiler caching disabled and no copied prior core/module/test binaries. Registered `guest_icu_version`, `guest_icu_unescape`, `guest_icu_utf_conversions` and `guest_icu_utf_memory` passed **4/4**; all **65/65** actual public-header CTests passed, with zero skips or failures. The audit reports 368 libraries and 12,814 exports. Provider linkage resolves only this fresh build’s ICU/libc/kernel PRXs. These results qualify the documentation head through the explicit code-equivalence checks. Conventions against the pinned `origin/main` and whitespace pass. Existing pinned dependency sources and source-built FFmpeg configuration package were verified separately. This is independent Linux component/header evidence, with no new Windows, macOS, PS5, sanitizer, full-product or later-main execution claim. Earlier evidence below retains its named historical scope. The declared predecessor and agreed landing order remain required. Earlier preserving rebase `4e4a4a132be9d7f10803ad462c09803cdeee5f84` on `6733079b2d01bb25aa1e6e771680da6a17363e3b`: source-preservation checks pass. All four owned production/header/fixture files and all six non-shared upstream source/header/fixture files retain their original bytes. The CMake registration, umbrella includes and both debt entries form the checked additive union. `git diff --check`, source conventions and the Python public-header audit pass; the audit reports 368 libraries and 12,266 unique exports with reachable declarations. This is a static audit, not header compilation. Earlier fresh exact-head validation for `4e4a4a132be9d7f10803ad462c09803cdeee5f84` on frozen base `6733079b2d01bb25aa1e6e771680da6a17363e3b`: Linux x86-64, GNU 16.2.1, Release, `BUILD_TESTING=ON`. The complete ICU module and every registered fixture were freshly built through the actual library CMake and original root helper bodies. `guest_icu_version`, `guest_icu_utf_conversions`, `guest_icu_utf_memory` passed **3/3**, with zero failures or skips; this includes the inherited #11013 version test and every owned topic fixture. All five C++ header units passed, covering standalone/repeated inclusion, the umbrella and composition with libc/kernel. The passing declaration audit is reused from the source owner’s exact-head receipt; C++ header compilation is fresh. The common libc/kernel runtime was freshly built once from that approved base and reused for this independent provider only after all 258 actual core project inputs, normal CMake/helper bodies, copied artifact hashes and provider paths were qualified against this head. Pinned source-built ZArchive/zstd archives were reused after source/hash/pin checks. This validates this independent ICU provider; it is not a seven-topic composite or a fresh core rebuild per branch. Earlier validation is Linux component evidence. No new native Windows, macOS, PS5, sanitizer, full-product or GPU result is claimed; Windows-only HostWrite-refusal paths were not executed by this Linux lane. Earlier platform, maintainer CI, firmware and private-integration evidence below retains its original head/base scope and does not qualify this rebased head. Historical evidence below retains its original source and platform scope. The author and reviewer results concern old head `58c283d6890d6faaeeb1ec5bd5fd17908ee1093b` or the explicitly named earlier head/base; the complete unchanged fixture bodies, including the 556 scalar-alias cases and guarded guest-memory/no-write paths, are preserved by the rebase. Linux x86-64, GCC 16.2.1, Release, `BUILD_TESTING=ON`, on main `3a2c51afd2ee6a824cd3a294912c65e6bbf2b768`. Built the complete ICU module through its production CMake and ran `guest_icu_utf_conversions` and `guest_icu_utf_memory`: 2/2 passed. Reused libc/kernel artifacts only after checking their 270-file Linux source/header dependency closure and artifact hashes against this base. Coverage includes every Unicode scalar and existing malformed/capacity/error cases, real shared guest mappings and aliases, cross-page buffers, optional output scalars, terminator-only writes and read-only no-write paths. The updated mapping fixture adds 556 scalar-alias cases across all five exports: length/error, substitution/error, length/substitution and three-way aliases; positive and zero outputs; warnings and latched failures; short/exact/extra/zero capacity, null preflight and empty conversions. It checks every destination unit and terminator canary. The lenient known-length rejection still writes length then overflow without reading the source or destination. Negative control: rebuilding the unchanged `c9e83c9c694705c45edd248a2b9e530e75e12a76` conversion source as the complete ICU module against the updated mapped fixture fails the new aliased-terminator canary assertion. The fixed module passes it. Public-header audit passed (368 libraries, 12,197 exports); three focused header/composition units, conventions and whitespace checks passed for `58c283d6890d6faaeeb1ec5bd5fd17908ee1093b`. A separate local composition of pinned #11013 plus #10961–#10967, using this updated conversion head, passes all 10 focused runtime tests, has 42 distinct public NIDs, and passes 11 header composition units including all 368 public umbrellas together. Every original production/test body and test registration remains present. This validates the local union; keep the declared integration predecessor #10964 and reconcile shared source-list, umbrella and debt files when rebasing. Historical [native Windows review](https://github.com/boykopovar/AnyPS5/pull/10965#pullrequestreview-5643476763) applies to the earlier head `c9e83c9c694705c45edd248a2b9e530e75e12a76`, tested on Windows 11, WinLibs GCC 15.2.0 r7, Release, merged into main `e05ba6feeb`. It reported repeated success including Windows read-only `RejectedWrites` cases. Later maintainer CI for old head `58c283d6890d6faaeeb1ec5bd5fd17908ee1093b` is qualified separately below. Neither historical scope validates the preserving rebased head; macOS library runtime and physical-console execution remain unverified. Independent [exact-head Linux re-review](https://github.com/boykopovar/AnyPS5/pull/10965#pullrequestreview-5644385545) by ahmadmuj validates `58c283d689` merged onto main `2e1c72239b`. The actual ICU module and both focused tests passed three repeats. The reviewer reports 75,954,840 aliased-output comparisons and about 642 million non-aliased calls against ICU 74.2 with zero mismatches, plus clean source ASan/UBSan runs; the prior-source control fails the new terminator-canary case. These are reviewer-reported Linux results, separate from author-run checks, historical Windows reports and hosted CI. Independent [firmware 13.42 native-code comparison](https://github.com/boykopovar/AnyPS5/pull/10965#issuecomment-6405802705) by BunnyFl covers only `u_strFromUTF8` and `u_strToUTF8`. The reviewer ran the firmware module's code on a PC against `UtfConversions.cpp` from `58c283d6890d6faaeeb1ec5bd5fd17908ee1093b`, compiled unchanged with an always-open, no-op `GuestArena::HostWrite` stand-in. The reported 400,000-call corpus, repeated three times, plus 2 million calls with two other seeds produced zero mismatches in return values, status, optional length output and all 512 destination bytes. Inputs include malformed UTF-8/UTF-16, explicit and NUL-terminated lengths, preflight/short/exact/extra/negative capacities, incoming warnings/errors, termination and partial surrogate output; targeted mutations were detected. This is reviewer-reported firmware code execution on a PC, not physical-console, full-library ABI, native Windows integration or guest-write validation. Null status pointers, null source pointers with nonzero length, read-only/watched mappings and scalar-output aliases are not established by this report. The reviewer found no firmware 13.42 exports named `u_strFromUTF8WithSub`, `u_strToUTF8WithSub` or `u_strFromUTF8Lenient`, including `_50`–`_89` suffixes; those three retain their source-backed and separate Linux differential evidence. Historical [maintainer CI run 40293533207](https://github.com/boykopovar/AnyPS5/actions/runs/40293533207) selects old head `58c283d6890d6faaeeb1ec5bd5fd17908ee1093b` merged on `b27cc8416f820e40ce187f165d34138e24373dd7`. Attempt 1 failed overall because four unchanged compiler-mode cases timed out in the Windows job; the focused UTF conversion/memory tests and headers passed. Attempt 2 succeeded: the fresh Windows job `121523996111` executed 1,639 passes and 810 policy-accepted skips out of 2,449 registered tests, including both UTF fixtures, 65 header cases and all four earlier timeout cases. Linux shown under attempt-2 API job `121523999013` is carried forward from the original attempt-1 execution `121474009987`, with 2,255 passes and 91 policy-accepted skips out of 2,346. Its original 08:51–09:35 execution precedes the 10:35 retry; no new Linux execution occurred. The retry does not diagnose the original timeout cause, erase the original failure or qualify the rebased head. ### 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: <!-- #PR, or none --> #10964 - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-25 11:35:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T11:35:13Z.

Review: CHANGES_REQUESTED


The conversion routines write directly to guest output buffers without opening GuestArena::HostWrite scopes. This affects both conversion loops (FromUtf8/ToUtf8 and the lenient path) and the terminator in Finish; the optional length/substitution outputs and error are guest-visible output pointers as well. Other direct guest-buffer writers in this tree guard their destination range (for example, fread in core/libs/prx/libc/src/FileAndHeap.cpp), and HostWrite provides the write-watch/shared-backing notification as well as Windows access handling. Please add appropriately sized guards for the output ranges before writing and handle failed Open() consistently. The host-array unit tests cannot catch this guest-memory integration issue, so a guest-backed conversion test would be useful.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642981461 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10965#pullrequestreview-5642981461). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T11:35:13Z. **Review:** CHANGES_REQUESTED --- The conversion routines write directly to guest output buffers without opening `GuestArena::HostWrite` scopes. This affects both conversion loops (`FromUtf8`/`ToUtf8` and the lenient path) and the terminator in `Finish`; the optional length/substitution outputs and `error` are guest-visible output pointers as well. Other direct guest-buffer writers in this tree guard their destination range (for example, `fread` in `core/libs/prx/libc/src/FileAndHeap.cpp`), and `HostWrite` provides the write-watch/shared-backing notification as well as Windows access handling. Please add appropriately sized guards for the output ranges before writing and handle failed `Open()` consistently. The host-array unit tests cannot catch this guest-memory integration issue, so a guest-backed conversion test would be useful.
MarcZX10 commented 2026-10-25 13:24:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T13:24:12Z.

Review: APPROVED


Reviewed updated head c9e83c9c694705c45edd248a2b9e530e75e12a76. The output scopes now cover the destination range and optional length/substitution outputs before conversion writes; the error output is guarded on invalid-argument paths. The new guest-backed mapped-memory test checks write-watch/shared aliases, cross-page destination and scalar writes, zero-capacity/no-write paths, and Windows read-only output ranges (including the error pointer).

I ran python3 tools/check_conventions.py --base upstream/main --head HEAD and git diff --check upstream/main...HEAD; both pass. The author reports the ICU build and focused Linux tests passing, with Windows-specific rejected-write cases added; the hosted product jobs are skipped and I did not run the full CMake suite locally. The previously requested guest-output guard gap is addressed, with no remaining blocking issue found in this scoped change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643375637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10965#pullrequestreview-5643375637). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T13:24:12Z. **Review:** APPROVED --- Reviewed updated head `c9e83c9c694705c45edd248a2b9e530e75e12a76`. The output scopes now cover the destination range and optional length/substitution outputs before conversion writes; the error output is guarded on invalid-argument paths. The new guest-backed mapped-memory test checks write-watch/shared aliases, cross-page destination and scalar writes, zero-capacity/no-write paths, and Windows read-only output ranges (including the error pointer). I ran `python3 tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check upstream/main...HEAD`; both pass. The author reports the ICU build and focused Linux tests passing, with Windows-specific rejected-write cases added; the hosted product jobs are skipped and I did not run the full CMake suite locally. The previously requested guest-output guard gap is addressed, with no remaining blocking issue found in this scoped change.
mantavisual commented 2026-10-25 13:44:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mantavisual on 2026-10-25T13:44:43Z.

Review: APPROVED


Checked against the pinned ICU 78.1 ustrtrns.cpp and ran it on Windows.

Semantics

  • The argument checks match ICU's u_strFromUTF8WithSub / u_strToUTF8WithSub (null source with nonzero length, srcLength < -1, negative capacity, null destination with capacity, and an out-of-range or surrogate subchar), as does the latched-error early return.
  • Substitution consumes maximal subparts, as ICU's U8_NEXT does: E0 80 gives two substitutions, and E0 A0 41 gives one before A.
  • ToUtf8 stops writing at the first character that does not fit and only counts the rest, like ICU's write loop followed by its preflight loop.
  • Lenient with srcLength >= 0 and destCapacity < srcLength sets *pDestLength = srcLength and U_BUFFER_OVERFLOW_ERROR and returns null, as ICU does.
  • Finish follows ICU's termination rules (__TERMINATE_STRING).

Windows (Windows 11, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, this head merged into main e05ba6feeb)

  • Both test targets build with no warnings in the ICU sources.
  • ctest -R "^guest_icu_utf_(conversions|memory)$" --repeat until-fail:5: 5 of 5 passes each.
  • The _WIN32-only RejectedWrites cases, which the description says were not executed, run unconditionally from main() here and pass. Read-only tracked views refuse HostWrite, and every refused conversion leaves all output bytes unchanged.

Note (not blocking)
The progress report lists the five as "declared as stubs" (-0.02%) because Validate, Length and Finish reach NotImplemented_nid_no_patch. For the null error code, ICU 78.1 reads *pErrorCode unchecked in all five functions (its first statement is if(U_FAILURE(*pErrorCode))), so that input crashes there rather than being unknown. Other libraries here throw std::invalid_argument for inputs the source does not check (for example, libSceLibreSsl's digests). The size-limit guards in Length and Finish are a different case, since ICU's int32_t arithmetic would overflow, so the exports would still count as stubs either way.

Not checked: console behaviour, and integration with the other ICU PRs (#10961 to #10964).

Reviewed with AI assistance (Claude Code). The checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643476763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10965#pullrequestreview-5643476763). Originally posted by [mantavisual](https://github.com/mantavisual) on 2026-10-25T13:44:43Z. **Review:** APPROVED --- Checked against the pinned ICU 78.1 [`ustrtrns.cpp`](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/ustrtrns.cpp) and ran it on Windows. **Semantics** - The argument checks match ICU's `u_strFromUTF8WithSub` / `u_strToUTF8WithSub` (null source with nonzero length, `srcLength < -1`, negative capacity, null destination with capacity, and an out-of-range or surrogate `subchar`), as does the latched-error early return. - Substitution consumes maximal subparts, as ICU's `U8_NEXT` does: `E0 80` gives two substitutions, and `E0 A0 41` gives one before `A`. - `ToUtf8` stops writing at the first character that does not fit and only counts the rest, like ICU's write loop followed by its preflight loop. - Lenient with `srcLength >= 0` and `destCapacity < srcLength` sets `*pDestLength = srcLength` and `U_BUFFER_OVERFLOW_ERROR` and returns null, as ICU does. - `Finish` follows ICU's termination rules (`__TERMINATE_STRING`). **Windows** (Windows 11, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, this head merged into `main` `e05ba6feeb`) - Both test targets build with no warnings in the ICU sources. - `ctest -R "^guest_icu_utf_(conversions|memory)$" --repeat until-fail:5`: 5 of 5 passes each. - The `_WIN32`-only `RejectedWrites` cases, which the description says were not executed, run unconditionally from `main()` here and pass. Read-only tracked views refuse `HostWrite`, and every refused conversion leaves all output bytes unchanged. **Note (not blocking)** The progress report lists the five as "declared as stubs" (-0.02%) because `Validate`, `Length` and `Finish` reach `NotImplemented_nid_no_patch`. For the null error code, ICU 78.1 reads `*pErrorCode` unchecked in all five functions (its first statement is `if(U_FAILURE(*pErrorCode))`), so that input crashes there rather than being unknown. Other libraries here throw `std::invalid_argument` for inputs the source does not check (for example, libSceLibreSsl's digests). The size-limit guards in `Length` and `Finish` are a different case, since ICU's `int32_t` arithmetic would overflow, so the exports would still count as stubs either way. Not checked: console behaviour, and integration with the other ICU PRs (#10961 to #10964). Reviewed with AI assistance (Claude Code). The checks above were run locally on my machine.
ahmadmuj commented 2026-10-25 15:03:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T15:03:08Z.

Review: APPROVED


Reviewed head c9e83c9c694705c45edd248a2b9e530e75e12a76, merged locally onto main 3a2c51afd2ee6a824cd3a294912c65e6bbf2b768 (clean).

What I ran, Linux x86-64, GCC 13.3, Release:

  • Merged tree, full configure with BUILD_TESTING=ON, built libSceIcu, guest_icu_utf_conversions_tests and guest_icu_utf_memory_tests only: both tests pass, 3 repeats each.
  • A differential harness that links the built libSceIcu.prx and calls all five exports next to the real system ICU 74.2 (libicuuc.so.74, u_*_74). The 74.2 and pinned 78.1 ustrtrns.cpp differ only in the casts in _appendUTF8, and __TERMINATE_STRING is the same. Each call compares the return value, every destination unit plus 8 canary units past capacity, *pDestLength, *pNumSubstitutions and the error code.
    • UTF-8 in: all 0-3 byte strings, 20M sampled 4-byte strings, 24M random strings up to 40 bytes biased to C0/C1/E0/ED/F0/F4/F5/FF/80/BF and NUL. UTF-16 in: every single unit, all 2-3 unit combinations of 22 edge units (lone/reversed surrogates, FFFE/FFFF, 7FF/800, NUL), plus random strings.
    • Explicit length and -1. Every capacity from 0 to the needed length + 2, plus null dest. Subchar -1, -2, 0, 0x1A, 0x7FF, 0x800, 0xFFFD, 0xFFFF, 0x10000, 0x10FFFF, and the invalid ones. Initial error 0, -124, -127, 1, 15. The argument-error cases from the ICU check.
    • Each source ends right before a PROT_NONE page, so a read past the end faults.
    • About 10.5 billion compared calls, 0 mismatches. A second pass compiles UtfConversions.cpp unmodified with ASan+UBSan (about 460M calls): clean. Three scratch mutants were caught, so the harness sees these paths.

Approving. One small thing, not blocking:

  • UtfConversions.cpp:64-70: Finish writes *length, then terminates without re-checking the error. ICU writes *pDestLength and then runs __TERMINATE_STRING, which only acts if(U_SUCCESS(*pErrorCode)) (ustring.cpp L1438). So it differs only when the length or substitution output aliases the error, which is the case your memory test covers. Example: u_strFromUTF8 on "abc", capacity 4, pDestLength == pErrorCode: ICU leaves dest[3] alone and the error at 3; this writes dest[3] = 0. At capacity 3, ICU keeps 3 and this sets -124. if (*error > 0) return; right after the length write would match it. GuestIcuUtfMemory.cpp:112 checks only *status, so a canary check on destination[3] there would catch it.

Not checked: console behaviour, Windows, the guest-mapped paths beyond your test, and integration with the other ICU PRs.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643781074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10965#pullrequestreview-5643781074). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T15:03:08Z. **Review:** APPROVED --- Reviewed head `c9e83c9c694705c45edd248a2b9e530e75e12a76`, merged locally onto main `3a2c51afd2ee6a824cd3a294912c65e6bbf2b768` (clean). What I ran, Linux x86-64, GCC 13.3, Release: - Merged tree, full configure with `BUILD_TESTING=ON`, built `libSceIcu`, `guest_icu_utf_conversions_tests` and `guest_icu_utf_memory_tests` only: both tests pass, 3 repeats each. - A differential harness that links the built `libSceIcu.prx` and calls all five exports next to the real system ICU 74.2 (`libicuuc.so.74`, `u_*_74`). The 74.2 and pinned 78.1 `ustrtrns.cpp` differ only in the casts in `_appendUTF8`, and `__TERMINATE_STRING` is the same. Each call compares the return value, every destination unit plus 8 canary units past capacity, `*pDestLength`, `*pNumSubstitutions` and the error code. - UTF-8 in: all 0-3 byte strings, 20M sampled 4-byte strings, 24M random strings up to 40 bytes biased to C0/C1/E0/ED/F0/F4/F5/FF/80/BF and NUL. UTF-16 in: every single unit, all 2-3 unit combinations of 22 edge units (lone/reversed surrogates, FFFE/FFFF, 7FF/800, NUL), plus random strings. - Explicit length and -1. Every capacity from 0 to the needed length + 2, plus null dest. Subchar -1, -2, 0, 0x1A, 0x7FF, 0x800, 0xFFFD, 0xFFFF, 0x10000, 0x10FFFF, and the invalid ones. Initial error 0, -124, -127, 1, 15. The argument-error cases from the ICU check. - Each source ends right before a `PROT_NONE` page, so a read past the end faults. - About 10.5 billion compared calls, 0 mismatches. A second pass compiles `UtfConversions.cpp` unmodified with ASan+UBSan (about 460M calls): clean. Three scratch mutants were caught, so the harness sees these paths. Approving. One small thing, not blocking: - `UtfConversions.cpp:64-70`: `Finish` writes `*length`, then terminates without re-checking the error. ICU writes `*pDestLength` and then runs `__TERMINATE_STRING`, which only acts `if(U_SUCCESS(*pErrorCode))` (ustring.cpp L1438). So it differs only when the length or substitution output aliases the error, which is the case your memory test covers. Example: `u_strFromUTF8` on `"abc"`, capacity 4, `pDestLength == pErrorCode`: ICU leaves `dest[3]` alone and the error at 3; this writes `dest[3] = 0`. At capacity 3, ICU keeps 3 and this sets -124. `if (*error > 0) return;` right after the length write would match it. `GuestIcuUtfMemory.cpp:112` checks only `*status`, so a canary check on `destination[3]` there would catch it. Not checked: console behaviour, Windows, the guest-mapped paths beyond your test, and integration with the other ICU PRs.
ahmadmuj commented 2026-10-25 17:39:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T17:39:25Z.

Review: APPROVED


Re-checked head 58c283d6890d6faaeeb1ec5bd5fd17908ee1093b, merged locally onto main 2e1c72239b23cf9b9e8ceb2d04fab25296374d92 (clean). Range-diff vs c9e83c9: the first three commits are unchanged, so this covers the new one.

What I ran, Linux x86-64, GCC 13.3, Release:

  • Built libSceIcu and both test targets: guest_icu_utf_conversions and guest_icu_utf_memory pass, 3 repeats each.
  • Red control: with c9e83c9's UtfConversions.cpp swapped in, guest_icu_utf_memory fails at "positive aliased status preserves terminator canary". With the new line it passes. So the new test catches the old behaviour.
  • The same differential harness as before, now with an aliased-output mode: pDestLength == pErrorCode, pNumSubstitutions == pErrorCode, and both, for all five exports against system ICU 74.2. Inputs are 5 fixed strings per side (empty, ASCII, malformed, supplementary, surrogate/trail-byte edges) plus 20,000 random ones, explicit length only. It runs every capacity up to 2n+4 plus null dest, subchar -1/0/0xFFFD/0x10000, initial error 0/-124/-127, and checks the canaries past the destination. Your memory test already covers the -1 mode and the latched-error case.
    • New head: 75,954,840 calls, 0 mismatches. The same run under ASan+UBSan (from source) is clean.
    • Control with c9e83c9's UtfConversions.cpp: 51,408,567 mismatches in the same calls, all the terminator and error cases from my earlier note.
    • Non-aliased rerun on the new build (argument errors, all 0-2 byte and every 4th 3-byte UTF-8 string, all 1-unit UTF-16 plus edge-unit combinations, random strings): 642M calls, 0 mismatches.

Approving again. The fix is what ICU's __TERMINATE_STRING does, and the alias cases match ICU in every run above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644385545 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10965#pullrequestreview-5644385545). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T17:39:25Z. **Review:** APPROVED --- Re-checked head `58c283d6890d6faaeeb1ec5bd5fd17908ee1093b`, merged locally onto main `2e1c72239b23cf9b9e8ceb2d04fab25296374d92` (clean). Range-diff vs `c9e83c9`: the first three commits are unchanged, so this covers the new one. What I ran, Linux x86-64, GCC 13.3, Release: - Built `libSceIcu` and both test targets: `guest_icu_utf_conversions` and `guest_icu_utf_memory` pass, 3 repeats each. - Red control: with `c9e83c9`'s `UtfConversions.cpp` swapped in, `guest_icu_utf_memory` fails at "positive aliased status preserves terminator canary". With the new line it passes. So the new test catches the old behaviour. - The same differential harness as before, now with an aliased-output mode: `pDestLength == pErrorCode`, `pNumSubstitutions == pErrorCode`, and both, for all five exports against system ICU 74.2. Inputs are 5 fixed strings per side (empty, ASCII, malformed, supplementary, surrogate/trail-byte edges) plus 20,000 random ones, explicit length only. It runs every capacity up to 2n+4 plus null dest, subchar -1/0/0xFFFD/0x10000, initial error 0/-124/-127, and checks the canaries past the destination. Your memory test already covers the -1 mode and the latched-error case. - New head: 75,954,840 calls, 0 mismatches. The same run under ASan+UBSan (from source) is clean. - Control with `c9e83c9`'s `UtfConversions.cpp`: 51,408,567 mismatches in the same calls, all the terminator and error cases from my earlier note. - Non-aliased rerun on the new build (argument errors, all 0-2 byte and every 4th 3-byte UTF-8 string, all 1-unit UTF-16 plus edge-unit combinations, random strings): 642M calls, 0 mismatches. Approving again. The fix is what ICU's `__TERMINATE_STRING` does, and the alias cases match ICU in every run above.
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!10965
No description provided.