feat(libSceIcu): implement escape decoding #10961
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10961"
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:21:46Z.
What
Implement
u_unescapeandu_unescapeAt: numeric, octal, ANSI, control and generic escapes; UTF-16 surrogate joining; guest-ABI callbacks and offset updates; preflight, bounded writes and malformed-input handling. Preserve the reference implementation's eight-digit braced-hex rejection despite its public-header wording.Contracts follow pinned ICU 78.1 ustring.cpp and ustring.h. Names and NIDs match the pinned PS5 3.20 inventory. Escape behavior and ABI on console hardware remain unverified; firmware availability/routing and invalid-input and size limits remain in debt. No new dependency is added.
Typed declarations are reachable through
libSceIcu.hpp; source and tests use those canonical declarations. The branch is rebased onto frozen main6733079b2d01bb25aa1e6e771680da6a17363e3b, which contains the actual #11013 mergebd1b31548c4f8a21de87b3856b881083ca80492a. All merged invariant/version implementations, canonical declarations, test registrations and debt are preserved alongside the escape-decoding topic.BunnyFl’s firmware 13.42 report records
u_getVersionreturning78.1.0.0withsystem_ex/common_ex/lib/libSceIcu.sprxexecuted under an emulator. Neitheru_unescapenoru_unescapeAtis among the checked native module’s 299 exports; only 104 of the 661 NIDs in the older 3.20 inventory match that export table. These older-inventory compatibility APIs remain implemented. Availability and routing across firmware versions, and escape-function behavior on console hardware, are not established by this report.The extended landing order is agreed: #11013 → #10961 → #10962 → #10963 → #10964 → #10965 → #10966 → #10967 → #11088. The later numeric topic declares #10967; this PR retains #11013 as fulfilled integration history after its merge. All implementations, source/test registrations and updated firmware debt must survive the successive rebases.
Tested
Manual CI
40445885976, attempt 1, completed successfully for the ordered five-PR composition #114726e97111223→ #1097578cb208c0c→ #112694ccb760d12→ #109505746326efc→ #10961844e39236f, on frozen main09f9a63f6b85aec9f36ce5d0d46f41c37cbd86fd. This PR’s tested head is844e39236f0ea90203751894aad259bbc703748a.121997011318121997011314Both jobs passed
guest_jsc_string,guest_icu_unescape,guest_icu_version, all 65 public-header CTests andpatched_libraries; both skip validators passed. This qualifies the recorded five-PR Linux/Windows Release composition, not either PR alone or later main. Ancillary macOS/relinker-ASan jobs do not establish macOS-library, library-ASan or native-console coverage. The declared #11013 predecessor and agreed ICU landing/integration order remain unchanged. Earlier entries below retain their original heads, compositions, outcomes and historical status.Maintainer CI 40382857757/a1 has mixed results; the full run failed on Linux. Exact composition: base
6b16c9c6499a, then #10961@844e39236f0e→ #10953@8b4bb4d239ad→ #11235@3e333ce0fc5d→ #11337@d84c522f4bda→ #10950@5746326efc33.Windows job 121783493660 passed its normal Release build/library targets and suite: 1,692 passed, 815 validated expected skips, zero failed / 2,507. Linux job 121783493789 built successfully but reported 2,306 passed, 93 observed skips, two failed / 2,401:
guest_sigvec_modulesandguest_posix_spawn. Its skip validator was skipped; those 93 skips are not policy-qualified.On both platforms,
guest_icu_versionandguest_icu_unescapeand all 65 header cases (public_headersplus 64 compilation batches) passed. This qualifies only the exact five-input composition, not an isolated head, newer main, other ICU follower heads, console equivalence or an overall green run. No source changes or dependency waivers result from this evidence. Existing prerequisite and review gates remain. Earlier entries below retain their historical source/base scopes.Current preserving-rebase head
844e39236f0ea90203751894aad259bbc703748ais clean on6733079b2d01bb25aa1e6e771680da6a17363e3b. The decoder implementation, canonical escape header and full escape test are byte-identical to published7010784ecedd722126d727a277b26ec9778a70f1; upstream #11013 implementation/header/version-test bytes and debt are preserved. Both runtime test registrations survive.git diff --checkandpython3 tools/check_conventions.py --base origin/mainpassed. Fresh exact-head validation for844e39236f0ea90203751894aad259bbc703748aon 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_unescapepassed 2/2, 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 declaration audit was run on this exact selected source tree.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.
Current 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 validation, retained with its original source/base scope:
Documentation follow-up
7010784ecedd722126d727a277b26ec9778a70f1records the firmware evidence only. The completecore/libstree (production code, public headers, CMake and tests) is byte-identical to published524ad73c3ebeea131638d6a8cd908e6992e7fdb8. Conventions and whitespace checks passed for the new documentation head. Existing runtime and header results below are reused from unchanged executable sources; no build, runtime rerun or header compilation was needed for this documentation change.Linux x86-64, GCC 16.2.1, Release,
BUILD_TESTING=ON. Built the complete changed ICU PRX through its actual library CMake, linked to the freshly rebuilt libc/kernel runtime from the same frozen base.guest_icu_unescapepassed, 1/1. Escape forms, malformed/truncated input, surrogate joining, seven exact callback-order/visible-offset probes (including indices near INT32_MAX), bounded UTF-16 prefixes and split-pair canaries, preflight lengths, and nonzero terminator sentinels. The earlier review follow-up changed tests only; production decoder source is unchanged.The repository-wide
public_headersaudit passed, and the canonical declaration header plus umbrella compiled independently with-Werror.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpassed for head524ad73c3ebeea131638d6a8cd908e6992e7fdb8. Validation covered the changed library and its runtime dependencies on Linux; Windows, macOS and console execution were not performed.#11013 has merged. Its five distinct invariant/version helpers are preserved in this rebase, including their source/header files,
guest_icu_versionregistration and debt. The agreed landing order remains #11013 first, then this PR and #10962–#10967, extended by #11088 as linked above. #11013 is a fulfilled integration predecessor; this ordering coordinates shared files and the APIs remain functionally independent.Existing pinned Linux integration evidence on base
3a2c51afd2combines #11013 head0fd2e0ce9fb870713022b1f2a369fb6b1ff28366with the seven ICU topic heads, including UTF alias correction58c283d6890d6faaeeb1ec5bd5fd17908ee1093b. The actual complete ICU library build and 10/10 runtime tests pass with zero skips; all 42 unique public exports are present. All 19 current input production/test sources and all eight registration blocks are preserved. The full public-header audit and 11 composition checks pass, including all 368 library umbrellas together. This validates the concrete mechanical merge sequence and is reused for the documentation update; it is not a new Windows or console run.Additional nine-topic Linux validation combines #11013
37d5137ea0, #11088a43b228a4ainput bytes and the current seven-topic series, including UTF alias fix58c283d689. The private normal-library build passed 11/11 runtime tests, retains 66 public exports, and passes 12 header-composition checks. The numeric test at a43 is byte-identical to the portability-corrected test that was compiled; its production/API/CMake inputs are unchanged. This evidence reuses the exact compiled input bytes, with frozen base5949d8bfand the explicitly qualified #10953 core composite from that base, rather than a pure-main or Windows combined run. The earlier unmodified numeric test at2098426fbffailed on LP64; that historical failure is superseded by a43’s applied test fix.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 thepoppfish on 2026-10-25T11:41:52Z.
Review: APPROVED
Reviewed exact head
8f40cf8e9f2b1a73c76492245146b3380e4e6248; no blocking findings. I compared the decoder with the pinned ICU 78.1 implementation, including offset restoration, lookahead through a local offset and the eight-digit braced-hex behavior. Console-version equivalence remains explicitly unverified in debt.Independent Windows 11 build 26200, MSYS2 UCRT64 GCC 16.2.0-6, CMake 4.3.1, Ninja 1.13.2, Release validation, adding the platform absent from the author's report:
Export.cppandUnescape.cpp) through its actual library CMake and ran the complete unmodifiedtests/Unescape.cppacross the resulting.prxDLL. Used the exact productionadd_test_executable/configure_windows_unwindhelpers andWindowsTestExit.cpp. No LTO, decoder replacement or test-body edit.NotImplemented_nid_no_patch, with the samestd::runtime_error(std::string(name) + " not implemented")body asGeneral.cpp. Full libc/kernel were not linked, so this is an isolated native library test, not a full runtime build.INT32_MAX. Both registered tests pass, 0.12 s total.characterAt(position++, context)to call the callback before incrementing. The complete submitted fixture still passes, while the additional probe fails at its visible-offset/order assertion. This is a scratch mutation, not an upstream failing baseline. The PR code itself is correct here; the probe would be useful extra regression coverage for the behavior described in the PR.python core/libs/tests/test_public_headers.py --audit-only: 368 libraries, 12,190 exports, unique declarations and umbrella coverage verified. Canonical API and umbrella headers compile together, twice included, with GCC-Werror -fsyntax-only.16ff208dc32cf3927ba1bae492eee363a5ae7ae8. Tree-only merge is clean (tree9c903fdf181eb84cca80fc2d1decdb98a5efa6f8); no merged-tree test run claimed.No PS5/title/GPU execution, NID-patched artifact execution, full product/runtime build, Linux/macOS run or hosted workflow claim. The author checkout remains clean and unchanged. AI-assisted review/testing: yes, OpenAI Codex.
Windows harness and additional callback probe replay
Save these files in a separate directory. Extract the unchanged
add_test_executablefunction from the pinned checkout's top-levelCMakeLists.txtandconfigure_windows_unwindfromcore/libs/CMakeLists.txtintoProductionHelpers.cmake. The supplied callback probe is additional coverage; the PR's full test source is read directly from the pinned checkout.For the control, save a copy of the decoder outside the checkout, replacing only
const auto initial = characterAt(position++, context);withconst auto initial = characterAt(position, context); ++position;. Configure a separate build with-DICU_UNESCAPE_SOURCE=<control.cpp>. Expect the additional callback test to fail and the submitted test to pass. Keep the GCC runtime DLL directory on PATH for both runs.CMakeLists.txtSupport.cppCallbackProbe.cppImported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T12:09:27Z.
Review: APPROVED
Reviewed head
8f40cf8e9f2b1a73c76492245146b3380e4e6248, merged locally onto maina5a780eaaa7f187fe8f5c7f2ef244f6a6dab2762(clean).What I ran, Linux x86-64, GCC 13.3:
BUILD_TESTING=ON, builtguest_icu_unescape_testsonly:guest_icu_unescapepasses 1/1.check_conventions.py --base origin/mainpasses.Unescape.cppunmodified against two references: theu_unescapeAt/u_unescapetext copied verbatim from the pinned ICU 78.1ustring.cpp(L1168-1429, only the macros shimmed), and the real systemlibicuuc.so.74(ICU 74.2). It compares the return value, the final*offset, the full callback trace (index plus the*offsetthe callback sees), and foru_unescapea sentinel-filled buffer at every capacity from 0 to len+3, plus null dest.\ u U x { } c 0 7 8 D d F A n C, plus D83D/DE00 foru_unescapeAtand 0xE9 foru_unescape), with start offsets INT32_MIN, -1, every index up to len+1, and INT32_MAX, and every truncatedlength.\u/\U/\x{}, the 10FFFF/110000/FFFFFFFF bounds, lead escapes times 37 tail forms (including\x{0000DFFF}), lead chains, and\c.dest[0] = 0on error) were both caught, so the harness does see these paths.ahead + 11there (ustring.cpp L1299), which is signed overflow, and UBSan flags it. Yourstd::minversion is defined. So that is fine and needs no debt line.Approving. Some small test notes, none blocking:
tests/Unescape.cpp:142:std::array<char16_t, 3> output{}starts zeroed, sooutput[1] == 0/output[2] == 0can't fail if the terminator write goes missing. Filling it with0xa55afirst would make those checks real.tests/Unescape.cpp:101: forcapacity < expected.size()the test only checks the tail sentinels, not the truncated prefix. For example,String("A\\u0042", u"AB")at capacity 1 never assertsoutput[1] == u'A'.positions(L37) records the reads but only its size is checked. The callback-order probe in the earlier review would cover this.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T13:25:02Z.
Review: APPROVED
Re-reviewed exact head
524ad73c3ebeea131638d6a8cd908e6992e7fdb8. The test-only update now checks nonzero terminator sentinels, each output capacity's written prefix and split-surrogate canaries, and callback read order/visible offsets including theINT32_MAXboundary. Production decoding code is unchanged from the previously reviewed implementation.I ran
python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/main...HEAD; both pass. The author reports the ICU library rebuild and focused Linux test passing. Earlier exact-head reviews independently compared the decoder with pinned ICU 78.1 and ran Linux and Windows test builds. Console-version equivalence remains the documented limitation.