Repository navigation
feat(libSceIcu): implement escape decoding - #10961
Conversation
Progress report (48c160c → 844e392)📉 System libraries: 51.09% (-0.01%, +1 implemented, +2 declared functions) ✅ 1 implemented
🆕 2 declared as stubs
Changed libraries (implemented exports)
|
thepoppfish
left a comment
There was a problem hiding this comment.
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:
- Built the complete changed ICU library (
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. - Focused parent harness supplies only
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. - Complete submitted test passes (0.03 s in final run). An additional cross-DLL probe passes seven guest-ABI callback cases: observed call order and the caller-visible offset, numeric/braced escapes, malformed input, recursive surrogate lookahead, failed lookahead and indices near
INT32_MAX. Both registered tests pass, 0.12 s total. - Mutation control changes only
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.- Conventions and whitespace pass against fetched main
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_executable function from the pinned checkout's top-level CMakeLists.txt and configure_windows_unwind from core/libs/CMakeLists.txt into ProductionHelpers.cmake. The supplied callback probe is additional coverage; the PR's full test source is read directly from the pinned checkout.
cmake -S <harness> -B <harness>/build -G Ninja -DCMAKE_BUILD_TYPE=Release -DICU_REPO=<checkout>
cmake --build <harness>/build
ctest --test-dir <harness>/build --output-on-failure -V
For the control, save a copy of the decoder outside the checkout, replacing only const auto initial = characterAt(position++, context); with const 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.txt
cmake_minimum_required(VERSION 3.20)
project(IcuUnescapeReview LANGUAGES CXX)
enable_testing()
set(CMAKE_CXX_STANDARD 20)
get_filename_component(ICU_DEFAULT_REPO "${CMAKE_CURRENT_SOURCE_DIR}/../review-10961" ABSOLUTE)
set(ICU_REPO "${ICU_DEFAULT_REPO}" CACHE PATH "Exact PR checkout")
set(LIBS_INCLUDE_DIR "${ICU_REPO}/core/libs")
set(BUILD_TESTING ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include("${CMAKE_CURRENT_SOURCE_DIR}/ProductionHelpers.cmake")
add_library(anyps5_windows_test_exit OBJECT "${ICU_REPO}/cmake/WindowsTestExit.cpp")
add_subdirectory("${ICU_REPO}/core/libs/prx/libSceIcu" icu)
set(ICU_UNESCAPE_SOURCE "" CACHE FILEPATH "Optional scratch decoder control")
if(ICU_UNESCAPE_SOURCE)
get_target_property(ICU_SOURCES libSceIcu SOURCES)
list(REMOVE_ITEM ICU_SOURCES "${ICU_REPO}/core/libs/prx/libSceIcu/Unescape.cpp")
set_property(TARGET libSceIcu PROPERTY SOURCES ${ICU_SOURCES} "${ICU_UNESCAPE_SOURCE}")
endif()
target_sources(libSceIcu PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Support.cpp")
set_target_properties(libSceIcu PROPERTIES PREFIX "" SUFFIX ".prx")
add_test_executable(icu_callback_probe CallbackProbe.cpp)
target_include_directories(icu_callback_probe PRIVATE "${LIBS_INCLUDE_DIR}")
target_link_libraries(icu_callback_probe PRIVATE libSceIcu)
configure_windows_unwind(icu_callback_probe)
add_test(NAME icu_callback_probe COMMAND icu_callback_probe)
set_tests_properties(icu_callback_probe PROPERTIES TIMEOUT 10 ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceIcu>")
Support.cpp
#include "prx/libc/include/General.hpp"
#include <stdexcept>
#include <string>
extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* name) {
throw std::runtime_error(std::string(name) + " not implemented");
}
CallbackProbe.cpp
#include "prx/libSceIcu/libSceIcu.hpp"
#include <cstdint>
#include <cstdio>
#include <limits>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
namespace {
using Observation = std::pair<std::int32_t, std::int32_t>;
struct State {
std::u16string text;
std::int32_t base;
std::int32_t* offset;
std::vector<Observation> observed;
};
char16_t APS5_VABI Read(std::int32_t index, void* context) {
auto& state = *static_cast<State*>(context);
state.observed.emplace_back(index - state.base, *state.offset - state.base);
const auto relative = static_cast<std::int64_t>(index) - state.base;
if (relative < 0 || relative >= static_cast<std::int64_t>(state.text.size()))
throw std::runtime_error("callback read outside declared text");
return state.text[static_cast<std::size_t>(relative)];
}
void Check(std::u16string text, std::int32_t expected, std::int32_t consumed,
std::vector<Observation> observations, std::int32_t base = 0) {
std::int32_t offset = base;
State state{std::move(text), base, &offset, {}};
const auto length = static_cast<std::int32_t>(static_cast<std::int64_t>(base) + state.text.size());
const auto result = u_unescapeAt_nid_postfix(Read, &offset, length, &state);
if (result != expected || offset - base != consumed || state.observed != observations)
throw std::runtime_error("callback value, visible offsets or order differs");
}
}
int main() {
try {
Check(u"u0041!", 0x41, 5, {{0,1},{1,1},{2,2},{3,3},{4,4}});
Check(u"x{41}", 0x41, 5, {{0,1},{1,1},{2,2},{3,3},{4,4}});
Check(u"u12", -1, 0, {{0,1},{1,1},{2,2}});
Check(u"uD83D\\uDE00", 0x1f600, 11,
{{0,1},{1,1},{2,2},{3,3},{4,4},{5,5},{6,5},{7,5},{8,5},{9,5},{10,5}});
Check(u"uD800\\u12", 0xd800, 5,
{{0,1},{1,1},{2,2},{3,3},{4,4},{5,5},{6,5},{7,5},{8,5}});
Check(std::u16string(u"uD83D") + char16_t{0xde00}, 0x1f600, 6,
{{0,1},{1,1},{2,2},{3,3},{4,4},{5,5}}, std::numeric_limits<std::int32_t>::max() - 6);
Check(u"u", -1, 0, {{0,1}}, std::numeric_limits<std::int32_t>::max() - 1);
std::puts("Seven cross-DLL guest callback order/visible-offset/boundary cases pass");
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
return 1;
}
}
ahmadmuj
left a comment
There was a problem hiding this comment.
Reviewed head 8f40cf8e9f2b1a73c76492245146b3380e4e6248, merged locally onto main a5a780eaaa7f187fe8f5c7f2ef244f6a6dab2762 (clean).
What I ran, Linux x86-64, GCC 13.3:
- Merged tree, full configure with
BUILD_TESTING=ON, builtguest_icu_unescape_testsonly:guest_icu_unescapepasses 1/1.check_conventions.py --base origin/mainpasses. - A differential harness. It runs your
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.- Exhaustive inputs up to 7 units over an escape-heavy alphabet (
\ 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. - Structured cases: 0-10 digit
\u/\U/\x{}, the 10FFFF/110000/FFFFFFFF bounds, lead escapes times 37 tail forms (including\x{0000DFFF}), lead chains, and\c. - 110M random strings.
- About 59.7 billion compared cases in total, 0 mismatches between any pair in those sets, 0 sanitizer reports in your code (ASan+UBSan on the length-6, structured and 10M random sets).
- Two scratch mutants (tail limit 11 to 12, and no
dest[0] = 0on error) were both caught, so the harness does see these paths.
- Exhaustive inputs up to 7 units over an escape-heavy alphabet (
- The only difference I found is in a separate run at callback indices within 11 of INT32_MAX. ICU computes
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. - ICU 78.1 and 74.2 agreed on every case, the high-offset one included.
- Negative capacity with a nonnull dest: both ICU versions return the full length and write nothing. Your debt entry already covers the throw.
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.
8f40cf8 to
524ad73
Compare
|
Addressed all three test notes in Rebased onto |
MarcZX10
left a comment
There was a problem hiding this comment.
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 the INT32_MAX boundary. Production decoding code is unchanged from the previously reviewed implementation.
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 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.
|
I checked this against firmware 13.42's
|
|
Thanks for checking the actual 13.42 module. Recorded your report in debt at This changes documentation only: production code, public headers, CMake and tests are byte-identical to Ready for re-review and merge when maintainers are satisfied. |
7010784 to
844e392
Compare
|
Rebased onto main Conventions and whitespace checks pass. Fresh exact-head Linux Release validation passed 2/2 CTests ( Please re-review and merge when the fresh required checks and maintainer review permit. |
|
@oneandonlydean, run 40382857757/a1 provides focused evidence for this exact head in the recorded five-input composition on The description preserves that scope and all earlier evidence and prerequisites. Please re-review these focused results; full-CI and existing review/integration gates remain open. |
|
CI Please re-review. The #11013 prerequisite and agreed ICU landing order remain unchanged; merge only when that order, current integration and review requirements are satisfied. |
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)