feat(libSceIcu): implement UTF-16 copy and concatenation #10964
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10964"
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:11Z.
What
Rebased onto frozen main
6e9b9134f6ed14e659d870a33118d164096551df, which includes the actual merge of #11760. Preserve its 112 throwingsceIcuUnknown_*_nid_no_patchexports and ABI-unverified debt together with the existing invariant/version and unescape implementation. The owned implementation, public declarations and fixtures remain byte-identical to the previous published head216b1118cd1ddffa68dc67948a856ef286e4d142; the debt conflict is resolved without including another open ICU topic.Implement
u_strcpy,u_strncpy,u_strcat,u_strncatandu_memcpyusing ICU 78.1 semantics and public ABI. Preserve raw UTF-16 code units, return pointers, nonpositive-count shortcuts, bounded-copy NUL behavior without padding and the reference implementation's bounded-concatenation terminator. Canonical declarations are inCopy.hpp, reachable throughlibSceIcu.hpp.Checked
HostWritescopes cover only actual writes: bounded-copy unused capacity stays unopened and concatenation opens only the appended suffix. Rejected scopes throw before stores. Preserve main's invariant/version and merged #10961 unescape sources, declarations, fixtures and debt. The owned implementation, header and both fixtures are byte-identical to3750dc2ddb7cc9e45703e29b467b2eff4eedc06a; shared registrations and includes are reconciled. #10963 remains the open immediate predecessor.The agreed landing order remains #11013 → #10961 → #10962 → #10963 → #10964 → #10965 → #10966 → #10967 → #11088. #11013 and #10961 have merged; the other open topics are not included or marked fulfilled by this independent branch.
Tested
2026-11-01 Windows CI: run 41295116341,
706c0fb6ed694244f507528b9e5c24364fe41932+ main26fa1212b82f76dd49cf12d65e445d6ff3e0844c: 1,680 selected CTests passed, 904 skipped, zero failed. All 10 ICU cases passed, includingguest_icu_copy,guest_icu_copy_guest_memory. The production ICU module built, linked and was NID-patched. This is the fixed single-PR integration, not the six-topic Windows union. General full-suite, skip-audit and header CTests were not run; native ABI/context/unload, existing dependencies, CI and review gates remain.2026-11-01: preserving rebase
706c0fb6ed694244f507528b9e5c24364fe41932onto 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_copy,guest_icu_copy_guest_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 #10963 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
4360e8f85b0bbd184199d9a3822dc30a8bd5f81eindependently 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_copy,guest_icu_copy_guest_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 guest-memory fixture executed Windows positive-count read-only rejection checks and reported
guest-mapped copy and readonly no-op checks passed; write-watch verified. The unavailable branch was absent from the actual JUnit, LastTest and verbose logs. 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:
4360e8f85b0bbd184199d9a3822dc30a8bd5f81eon frozen main6e9b9134f6ed14e659d870a33118d164096551df: Linux x86-64, normal-root Release,BUILD_TESTING=ON.guest_icu_version,guest_icu_unescape,guest_icu_copy,guest_icu_copy_guest_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 guest-memory fixture reported write-watch unavailable on this Linux host. Guest-mapped copies and read-only no-op checks ran; native write-watch and Windows-only positive-count read-only rejection subcases were not covered.
These results cover this standalone Linux component/header build. New-head macOS, PS5, sanitizer and full-product CI remain untested here; historical platform and private-composition evidence retains its recorded source scope. The declared predecessor and agreed ICU landing order remain required.
Historical validation before this rebase
Historical candidate
216b1118cd1ddffa68dc67948a856ef286e4d142on frozen mainaebeaa53f54dd4eccfe313f147807e3434588404: Linux x86-64, GNU 16.2.1, Release,BUILD_TESTING=ON. Fresh normal-root builds compiled the required libc/kernel runtime, complete ICU module and all registered ICU fixtures.guest_icu_version,guest_icu_unescape,guest_icu_copy,guest_icu_copy_guest_memorypassed 4/4, with zero failures or skips. All 65/65 normal public-header CTests passed: declaration audit plus 64 compilation shards, covering 699 groups, 368 libraries and 12,814 exports. Conventions, whitespace and source-preservation checks passed.This is an independent branch validation, with 197 fresh compiled objects and actual input/artifact/provider-path checks; no old core, module or fixture binaries were transferred. Existing repository-pinned prebuilt FFmpeg was used only for normal configuration and is absent from the ICU compile/link closure. No new Windows, macOS, PS5, sanitizer, GPU, full-product or remaining-series integration result is claimed; Windows-only HostWrite-refusal cases were not executed here.
Historical evidence remains source-bound:
3750dc2ddb7cc9e45703e29b467b2eff4eedc06aon6733079b2d01bb25aa1e6e771680da6a17363e3bpassed 3/3 Linux fixtures and five header units. wachi35676 reported Windows runs of0b58809a25merged onto14eb2cda22. Those runs and archived private ICU compositions do not qualify this rebase.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:33:58Z.
Review: CHANGES_REQUESTED
The four string-writing functions (
u_strcpy,u_strncpy,u_strcat, andu_strncat) write directly through guest pointers without opening aGuestArena::HostWritescope. Theu_memcpyimplementation does open one, so the current code handles this only for that export. This matters beyond Windows write permissions:GuestArenaBeginHostWritealso notifies the guest write-watch/shared-backing machinery, and the repository consistently scopes direct writes to guest buffers for that reason. For example,freadincore/libs/prx/libc/src/FileAndHeap.cppvalidates and guards its output range before writing. Please add appropriately sizedHostWriteguards around the string destinations (including the terminator for concatenation) and handle a failedOpen()consistently with the surrounding guest-memory APIs. The existing canary tests use ordinary host arrays and will not detect a missing guest-memory write notification; a focused GuestArena/write-watch test would cover this path.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T13:30:50Z.
Review: APPROVED
Reviewed updated head
0b58809a25dcb5c0c2d439f3156fa6133a71f2cc. The string writers now guard the exact destination range before mutation:strncpycovers only copied units,strcatincludes the replaced terminator, andstrncatincludes its appended terminator. The five copy exports reject a failed guard; nonpositive count paths still return without touching either pointer. The new direct guest mapping tests exercise shared backing/write-watch, precise page-boundary ranges, read-only unused capacity, canaries, and Windows refusal without partial writes.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 2/2 focused Linux tests plus pinned-source comparison. Windows-only rejected-write cases are present but unrun; hosted product jobs are skipped. The previously requested guest-write guards are in place. #10963 remains the declared integration predecessor.