feat(libSceIcu): implement UTF-8 and UTF-16 conversion #10965
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10965"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by AZLisme on 2026-10-25T11:22:18Z.
What
New preserving rebase:
c2076fe30ee3442546af395930defd74b7bfac2ais based on frozen main6e9b9134f6ed14e659d870a33118d164096551df, which contains the actual #11760 merge1dcfe038754ae612ac90cd8ee954deffec1938c4. All 112 inheritedsceIcuUnknown_*_nid_no_patchexports 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 publishedb0a817eaa977c38ca24c0253a290bc0f383ebe7e. 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:
b0a817eaa977c38ca24c0253a290bc0f383ebe7eon frozen mainaebeaa53f54dd4eccfe313f147807e3434588404includes the actual #10961 merge2ab073a1e7889d009edaabd84ab8cb10ce829156and the earlier merged #11013 helpers. All owned implementation, declaration and fixture bytes are unchanged from published4e4a4a132be9d7f10803ad462c09803cdeee5f84. 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_strToUTF8WithSubandu_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::HostWritescopes 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 is4e4a4a132be9d7f10803ad462c09803cdeee5f84on approved main6733079b2d01bb25aa1e6e771680da6a17363e3b, which contains the actual #11013 mergebd1b31548c4f8a21de87b3856b881083ca80492a. The landed invariant/version source, headers, fixture and debt are retained. Conversion implementation/header and both complete conversion/memory fixtures are byte-identical to58c283d6890d6faaeeb1ec5bd5fd17908ee1093b. 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+ main26fa1212b82f76dd49cf12d65e445d6ff3e0844c: 1,679 passed, 904 skipped, one failed.guest_avplayeralone 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
30303a5743bc7bed9db89efe8602eae904c0516donto fixed main26fa1212b82f76dd49cf12d65e445d6ff3e0844c. Linux GCC 16.2.1 Release: baseline 61 plain + 4 logging-enabled runtime CTests; private SIG-plus-six-ICU union4908848dab02fb1f0a9fad7e9525ddb8a628177a71 + 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 candidate8a5c8c499f0e0a157bd110430c1d99ee73bb0d47(tree620649fa8b0512d9c7e114c670342a691fd1433a) combines #10953 at581d45c282371af828efec2a8cec6f43beacc68awith 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_FILEset 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/nminspection 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 controlledstd::abortchild 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(topic207ac4b5ecfe). Against pinned main08a10d225306ad102b57408e2ef7566bcfb829b2, 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(tree446a6e346d3c6fac2e19e358d4376376778c7ae9), 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, #1096328cc96f3be1e16d2e3f098b0ae5b77b4fea85e09, #109644360e8f85b0bbd184199d9a3822dc30a8bd5f81e, #10965c2076fe30ee3442546af395930defd74b7bfac2a, #10966491e27444d83b53bc215a94edf132aee6a4707d7, #10967babf2bc72012bd926f35408b3d602d162a5ecd1b.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_memoryandguest_icu_utf_memory, alongside 13 heap/allocator cases; the converter-callback fixture passed in both lanes. Production NID patching plusreadelf/nminspection 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
c2076fe30ee3442546af395930defd74b7bfac2aindependently on its frozen main6e9b9134f6ed14e659d870a33118d164096551df. Windows x86-64, GitHub-hostedwin25-vs2026image20261021.278.1(OS build10.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_memorypassed 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
RejectedWritesdestination, scalar and status rejection checks, including unchanged outputs. Native preprocessing retained_WIN32and the original abortingRequirechecks 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:
c2076fe30ee3442546af395930defd74b7bfac2aon frozen main6e9b9134f6ed14e659d870a33118d164096551df: Linux x86-64, normal-root Release,BUILD_TESTING=ON.guest_icu_version,guest_icu_unescape,guest_icu_utf_conversions,guest_icu_utf_memorypassed 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
c2076fe30ee3442546af395930defd74b7bfac2amerged with main200f40814dd6041072b089e6ae05edb42d2a8d52on 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, andguest_icu_utf_conversions,guest_icu_utf_memory,guest_icu_version,guest_icu_unescapepassed both repetitions ofctest --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
b0a817eaa977c38ca24c0253a290bc0f383ebe7efollows runtime-testedeccc0082eac15184908890b1032e829b2431d491on frozen mainaebeaa53f54dd4eccfe313f147807e3434588404. 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. Registeredguest_icu_version,guest_icu_unescape,guest_icu_utf_conversionsandguest_icu_utf_memorypassed 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/mainand 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
4e4a4a132be9d7f10803ad462c09803cdeee5f84on6733079b2d01bb25aa1e6e771680da6a17363e3b: 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
4e4a4a132be9d7f10803ad462c09803cdeee5f84on frozen base6733079b2d01bb25aa1e6e771680da6a17363e3b: 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_memorypassed 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
58c283d6890d6faaeeb1ec5bd5fd17908ee1093bor 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 main3a2c51afd2ee6a824cd3a294912c65e6bbf2b768. Built the complete ICU module through its production CMake and ranguest_icu_utf_conversionsandguest_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
c9e83c9c694705c45edd248a2b9e530e75e12a76conversion 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 for58c283d6890d6faaeeb1ec5bd5fd17908ee1093b.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 maine05ba6feeb. It reported repeated success including Windows read-onlyRejectedWritescases. Later maintainer CI for old head58c283d6890d6faaeeb1ec5bd5fd17908ee1093bis 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
58c283d689merged onto main2e1c72239b. 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_strFromUTF8andu_strToUTF8. The reviewer ran the firmware module's code on a PC againstUtfConversions.cppfrom58c283d6890d6faaeeb1ec5bd5fd17908ee1093b, compiled unchanged with an always-open, no-opGuestArena::HostWritestand-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 namedu_strFromUTF8WithSub,u_strToUTF8WithSuboru_strFromUTF8Lenient, including_50–_89suffixes; those three retain their source-backed and separate Linux differential evidence.Historical maintainer CI run 40293533207 selects old head
58c283d6890d6faaeeb1ec5bd5fd17908ee1093bmerged onb27cc8416f820e40ce187f165d34138e24373dd7. 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 job121523996111executed 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 job121523999013is carried forward from the original attempt-1 execution121474009987, 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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T11:35:13Z.
Review: CHANGES_REQUESTED
The conversion routines write directly to guest output buffers without opening
GuestArena::HostWritescopes. This affects both conversion loops (FromUtf8/ToUtf8and the lenient path) and the terminator inFinish; the optional length/substitution outputs anderrorare guest-visible output pointers as well. Other direct guest-buffer writers in this tree guard their destination range (for example,freadincore/libs/prx/libc/src/FileAndHeap.cpp), andHostWriteprovides 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 failedOpen()consistently. The host-array unit tests cannot catch this guest-memory integration issue, so a guest-backed conversion test would be useful.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 HEADandgit 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.Imported from boykopovar/AnyPS5. Originally posted by mantavisual on 2026-10-25T13:44:43Z.
Review: APPROVED
Checked against the pinned ICU 78.1
ustrtrns.cppand ran it on Windows.Semantics
u_strFromUTF8WithSub/u_strToUTF8WithSub(null source with nonzero length,srcLength < -1, negative capacity, null destination with capacity, and an out-of-range or surrogatesubchar), as does the latched-error early return.U8_NEXTdoes:E0 80gives two substitutions, andE0 A0 41gives one beforeA.ToUtf8stops writing at the first character that does not fit and only counts the rest, like ICU's write loop followed by its preflight loop.srcLength >= 0anddestCapacity < srcLengthsets*pDestLength = srcLengthandU_BUFFER_OVERFLOW_ERRORand returns null, as ICU does.Finishfollows ICU's termination rules (__TERMINATE_STRING).Windows (Windows 11, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, this head merged intomaine05ba6feeb)ctest -R "^guest_icu_utf_(conversions|memory)$" --repeat until-fail:5: 5 of 5 passes each._WIN32-onlyRejectedWritescases, which the description says were not executed, run unconditionally frommain()here and pass. Read-only tracked views refuseHostWrite, 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,LengthandFinishreachNotImplemented_nid_no_patch. For the null error code, ICU 78.1 reads*pErrorCodeunchecked in all five functions (its first statement isif(U_FAILURE(*pErrorCode))), so that input crashes there rather than being unknown. Other libraries here throwstd::invalid_argumentfor inputs the source does not check (for example, libSceLibreSsl's digests). The size-limit guards inLengthandFinishare a different case, since ICU'sint32_tarithmetic 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.
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T15:03:08Z.
Review: APPROVED
Reviewed head
c9e83c9c694705c45edd248a2b9e530e75e12a76, merged locally onto main3a2c51afd2ee6a824cd3a294912c65e6bbf2b768(clean).What I ran, Linux x86-64, GCC 13.3, Release:
BUILD_TESTING=ON, builtlibSceIcu,guest_icu_utf_conversions_testsandguest_icu_utf_memory_testsonly: both tests pass, 3 repeats each.libSceIcu.prxand calls all five exports next to the real system ICU 74.2 (libicuuc.so.74,u_*_74). The 74.2 and pinned 78.1ustrtrns.cppdiffer only in the casts in_appendUTF8, and__TERMINATE_STRINGis the same. Each call compares the return value, every destination unit plus 8 canary units past capacity,*pDestLength,*pNumSubstitutionsand the error code.PROT_NONEpage, so a read past the end faults.UtfConversions.cppunmodified 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:Finishwrites*length, then terminates without re-checking the error. ICU writes*pDestLengthand then runs__TERMINATE_STRING, which only actsif(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_strFromUTF8on"abc", capacity 4,pDestLength == pErrorCode: ICU leavesdest[3]alone and the error at 3; this writesdest[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:112checks only*status, so a canary check ondestination[3]there would catch it.Not checked: console behaviour, Windows, the guest-mapped paths beyond your test, and integration with the other ICU PRs.
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T17:39:25Z.
Review: APPROVED
Re-checked head
58c283d6890d6faaeeb1ec5bd5fd17908ee1093b, merged locally onto main2e1c72239b23cf9b9e8ceb2d04fab25296374d92(clean). Range-diff vsc9e83c9: the first three commits are unchanged, so this covers the new one.What I ran, Linux x86-64, GCC 13.3, Release:
libSceIcuand both test targets:guest_icu_utf_conversionsandguest_icu_utf_memorypass, 3 repeats each.c9e83c9'sUtfConversions.cppswapped in,guest_icu_utf_memoryfails at "positive aliased status preserves terminator canary". With the new line it passes. So the new test catches the old behaviour.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.c9e83c9'sUtfConversions.cpp: 51,408,567 mismatches in the same calls, all the terminator and error cases from my earlier note.Approving again. The fix is what ICU's
__TERMINATE_STRINGdoes, and the alias cases match ICU in every run above.