feat(libSceIcu): implement the UText framework and the UChar string provider #23900

Open
larpsahur333 wants to merge 1 commit from upstream-pr/23900 into main
larpsahur333 commented 2026-11-19 21:17:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by larpsahur333 on 2026-11-19T21:17:53Z.


What

Twenty-two libSceIcu exports that answered NotImplemented_nid_no_patch now implement the UText framework and the UChar string provider, ported from ICU 68.2's utext.cpp onto the guest UText layout:

  • openers: utext_openUChars, utext_setup, utext_clone
  • index and iteration: utext_getNativeIndex, utext_setNativeIndex, utext_getPreviousNativeIndex, utext_moveIndex32, utext_next32, utext_previous32, utext_next32From, utext_previous32From, utext_current32, utext_char32At
  • text access: utext_nativeLength, utext_extract, utext_replace, utext_copy
  • properties and comparison: utext_equals, utext_isWritable, utext_freeze, utext_hasMetaData, utext_isLengthExpensive

utext_close was already implemented in UText.cpp and still handles the shared close protocol; this branch supplies the accessors and the provider it closes over.

The layout is not guessed. UTextAccess.cpp asserts at compile time that the UText fields land on the offsets UText.cpp already uses (magic 0, flags 4, extraSize 24, chunkNativeStart 32, chunkContents 48, pFuncs 56, pExtra 64, context 72, a 112, 144 bytes total) and that UTextFuncs puts close at offset 80, which is the slot utext_close reads. A guest-provided UText and one the library allocates therefore share one layout, and the provider's function table is APS5_VABI so guest code can call it through the utext_next32-style macros.

Still stubs, on purpose: utext_openUTF8, utext_openUnicodeString, utext_openConstUnicodeString, utext_openReplaceable and utext_openCharacterIterator. Their providers need the UTF-8 chunker and the guest UnicodeString, Replaceable and CharacterIterator models, which this library does not have yet; implementing them against the host ICU types would repeat the bundle-model mistake.

tools/progress.py: libraries 17536/39550 (44.34%) before, 17571/39563 (44.41%) after; libSceIcu alone 291/2759 (10.55%) to 326/2772 (11.76%).

Overlap with #23859

This branch and #23859 both edit Export.cpp, include/InventoryExports.hpp, include/LegacyExports.hpp, LegacyExports.cpp, libSceIcu.hpp and CMakeLists.txt, but they touch different exports and their hunks do not depend on each other. They conflict textually only; merge either one first and I will rebase the other.

Tested

Windows 11 x86-64, MinGW-w64 GCC 15.2.0 (x86_64-ucrt-posix-seh, WinLibs 15.2.0posix-14.0.0-ucrt-r7), CMake 3.29.2, Ninja.

guest_icu_utext (new, core/libs/prx/libSceIcu/tests/UTextAccess.cpp) passes on a guest-provided UText over A, U+1F600, B:

  • utext_openUChars fills the supplied struct, utext_nativeLength is 4, the index starts at 0
  • utext_next32 returns A, then joins the surrogate pair to U+1F600 and leaves the index at 3
  • utext_current32, utext_previous32, utext_setNativeIndex, utext_char32At, utext_getPreviousNativeIndex, utext_moveIndex32, utext_next32From and utext_previous32From all agree on that text
  • utext_extract returns the four units plus the terminator, and reports a preflight of 4 with an overflow status for a two-unit buffer
  • utext_clone fills a second supplied struct, copies the length, and utext_equals is false across different positions and true from the same one
  • utext_replace and utext_copy return U_NO_WRITE_PERMISSION on this read-only provider, and utext_freeze clears writability on the clone
  • an empty text opens, has length 0 and yields U_SENTINEL

The whole ICU suite passes: ctest -R "^guest_icu" reports 100% tests passed, 0 tests failed out of 77.

python core/libs/tests/test_public_headers.py --compiler g++: 413 libraries, 34733 exports: unique declarations and umbrella coverage verified.

python3 tools/debt_fold.py --check passes.

Not tested: no PS5 was involved, so the console's answers are unmeasured. A UText the library allocates takes its storage from the guest heap, which needs the relinked program's process metadata, so the test uses supplied structs; a real program gets the heap path. The UTF-8, UnicodeString, Replaceable and CharacterIterator openers stay stubs.

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 and the licence notice of code adapted from upstream
  • 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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5403115482 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23900). Originally posted by [larpsahur333](https://github.com/larpsahur333) on 2026-11-19T21:17:53Z. --- ### What Twenty-two `libSceIcu` exports that answered `NotImplemented_nid_no_patch` now implement the UText framework and the UChar string provider, ported from ICU 68.2's `utext.cpp` onto the guest `UText` layout: - openers: `utext_openUChars`, `utext_setup`, `utext_clone` - index and iteration: `utext_getNativeIndex`, `utext_setNativeIndex`, `utext_getPreviousNativeIndex`, `utext_moveIndex32`, `utext_next32`, `utext_previous32`, `utext_next32From`, `utext_previous32From`, `utext_current32`, `utext_char32At` - text access: `utext_nativeLength`, `utext_extract`, `utext_replace`, `utext_copy` - properties and comparison: `utext_equals`, `utext_isWritable`, `utext_freeze`, `utext_hasMetaData`, `utext_isLengthExpensive` `utext_close` was already implemented in `UText.cpp` and still handles the shared close protocol; this branch supplies the accessors and the provider it closes over. The layout is not guessed. `UTextAccess.cpp` asserts at compile time that the `UText` fields land on the offsets `UText.cpp` already uses (magic 0, flags 4, `extraSize` 24, `chunkNativeStart` 32, `chunkContents` 48, `pFuncs` 56, `pExtra` 64, `context` 72, `a` 112, 144 bytes total) and that `UTextFuncs` puts `close` at offset 80, which is the slot `utext_close` reads. A guest-provided `UText` and one the library allocates therefore share one layout, and the provider's function table is `APS5_VABI` so guest code can call it through the `utext_next32`-style macros. Still stubs, on purpose: `utext_openUTF8`, `utext_openUnicodeString`, `utext_openConstUnicodeString`, `utext_openReplaceable` and `utext_openCharacterIterator`. Their providers need the UTF-8 chunker and the guest `UnicodeString`, `Replaceable` and `CharacterIterator` models, which this library does not have yet; implementing them against the host ICU types would repeat the bundle-model mistake. `tools/progress.py`: `libraries 17536/39550 (44.34%)` before, `17571/39563 (44.41%)` after; `libSceIcu` alone `291/2759 (10.55%)` to `326/2772 (11.76%)`. ### Overlap with #23859 This branch and #23859 both edit `Export.cpp`, `include/InventoryExports.hpp`, `include/LegacyExports.hpp`, `LegacyExports.cpp`, `libSceIcu.hpp` and `CMakeLists.txt`, but they touch different exports and their hunks do not depend on each other. They conflict textually only; merge either one first and I will rebase the other. ### Tested Windows 11 x86-64, MinGW-w64 GCC 15.2.0 (`x86_64-ucrt-posix-seh`, WinLibs `15.2.0posix-14.0.0-ucrt-r7`), CMake 3.29.2, Ninja. `guest_icu_utext` (new, `core/libs/prx/libSceIcu/tests/UTextAccess.cpp`) passes on a guest-provided `UText` over `A`, U+1F600, `B`: - `utext_openUChars` fills the supplied struct, `utext_nativeLength` is 4, the index starts at 0 - `utext_next32` returns `A`, then joins the surrogate pair to U+1F600 and leaves the index at 3 - `utext_current32`, `utext_previous32`, `utext_setNativeIndex`, `utext_char32At`, `utext_getPreviousNativeIndex`, `utext_moveIndex32`, `utext_next32From` and `utext_previous32From` all agree on that text - `utext_extract` returns the four units plus the terminator, and reports a preflight of 4 with an overflow status for a two-unit buffer - `utext_clone` fills a second supplied struct, copies the length, and `utext_equals` is false across different positions and true from the same one - `utext_replace` and `utext_copy` return `U_NO_WRITE_PERMISSION` on this read-only provider, and `utext_freeze` clears writability on the clone - an empty text opens, has length 0 and yields `U_SENTINEL` The whole ICU suite passes: `ctest -R "^guest_icu"` reports `100% tests passed, 0 tests failed out of 77`. `python core/libs/tests/test_public_headers.py --compiler g++`: `413 libraries, 34733 exports: unique declarations and umbrella coverage verified`. `python3 tools/debt_fold.py --check` passes. Not tested: no PS5 was involved, so the console's answers are unmeasured. A `UText` the library allocates takes its storage from the guest heap, which needs the relinked program's process metadata, so the test uses supplied structs; a real program gets the heap path. The UTF-8, `UnicodeString`, `Replaceable` and `CharacterIterator` openers stay stubs. ### Checklist - [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 and the licence notice of code adapted from upstream - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-19 21:30:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T21:30:54Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 846aacfb8e:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_utext_tests built cleanly.
  • CTest (guest_icu_utext):
    1/1 Test #4012: guest_icu_utext ..................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/libSceIcu.hpp, core/libs/prx/libSceIcu/UTextAccess.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified UText and UTextFuncs struct layouts and offsets against 64-bit ABI and compile-time assertions in UTextAccess.cpp.
    • Verified StringAccess and StringLength for surrogate pair handling, boundary checks, and null-termination scanning.
    • Audited StringExtract buffer truncation and termination behavior via u_terminateUChars_nid_postfix.
    • Checked heap allocation, extraSpace management, and deallocation logic in utext_setup_nid_postfix and ShallowClone.
    • Verified all 22 exported functions in UTextAccess.cpp for correct null checks, status validation, and return types.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5983725102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23900#pullrequestreview-5983725102). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T21:30:54Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `846aacfb8e`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_utext_tests` built cleanly. - **CTest** (`guest_icu_utext`): ``` 1/1 Test #4012: guest_icu_utext .................. Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/libSceIcu.hpp`, `core/libs/prx/libSceIcu/UTextAccess.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified UText and UTextFuncs struct layouts and offsets against 64-bit ABI and compile-time assertions in UTextAccess.cpp. - Verified StringAccess and StringLength for surrogate pair handling, boundary checks, and null-termination scanning. - Audited StringExtract buffer truncation and termination behavior via u_terminateUChars_nid_postfix. - Checked heap allocation, extraSpace management, and deallocation logic in utext_setup_nid_postfix and ShallowClone. - Verified all 22 exported functions in UTextAccess.cpp for correct null checks, status validation, and return types. Looks Good To Me
PrivacyOnion commented 2026-11-19 21:33:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T21:33:54Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 909f6d41b8:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_utext_tests built cleanly.
  • CTest (guest_icu_utext):
    1/1 Test #4012: guest_icu_utext ..................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Export.cpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/InventoryExports.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/libSceIcu.hpp, core/libs/prx/libSceIcu/UTextAccess.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified UText struct and UTextFuncs layout, alignments, field offsets, and 64-bit ABI compile-time static asserts against libSceIcu specifications.
    • Audited utext_setup_nid_postfix for memory allocation, flags tracking (HeapAllocated, ExtraHeapAllocated, Open), and cleanup via text->pFuncs->close.
    • Audited utext_openUChars_nid_postfix parameter validation, EmptyText fallback for null source with length 0, and out-of-range length checks.
    • Audited StringAccess, StringLength, and StringExtract in UTextAccess.cpp for UTF-16 surrogate handling, bounds clamping via Pin(), and null-termination with u_terminateUChars_nid_postfix.
    • Audited ShallowClone and StringClone for extraSize handling, deep copy allocation, context offset pointer adjustments, and ProviderOwnsText lifecycle.
    • Verified error propagation with Failed(status) checks across all 22 exported UText functions and conformance with AGENTS.md conventions and debt fragment tracking.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5983761275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23900#pullrequestreview-5983761275). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T21:33:54Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `909f6d41b8`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_utext_tests` built cleanly. - **CTest** (`guest_icu_utext`): ``` 1/1 Test #4012: guest_icu_utext .................. Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Export.cpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/InventoryExports.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/libSceIcu.hpp`, `core/libs/prx/libSceIcu/UTextAccess.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified UText struct and UTextFuncs layout, alignments, field offsets, and 64-bit ABI compile-time static asserts against libSceIcu specifications. - Audited utext_setup_nid_postfix for memory allocation, flags tracking (HeapAllocated, ExtraHeapAllocated, Open), and cleanup via text->pFuncs->close. - Audited utext_openUChars_nid_postfix parameter validation, EmptyText fallback for null source with length 0, and out-of-range length checks. - Audited StringAccess, StringLength, and StringExtract in UTextAccess.cpp for UTF-16 surrogate handling, bounds clamping via Pin(), and null-termination with u_terminateUChars_nid_postfix. - Audited ShallowClone and StringClone for extraSize handling, deep copy allocation, context offset pointer adjustments, and ProviderOwnsText lifecycle. - Verified error propagation with Failed(status) checks across all 22 exported UText functions and conformance with AGENTS.md conventions and debt fragment tracking. Looks Good To Me
MarcZX10 commented 2026-11-20 12:02:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T12:02:30Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected implementation has no verified blocking defect; runtime checks were not run in this review.

What I ran

Inspected the prepared diff and relevant code at head 6c44b93a33b3e709d591aad96b1b0086d18996e6 using repo_read.py reader tools. No build or tests were run. The author reports Windows tests and checks in the PR description; those results were not independently verified.

Results

Check Result Note
Diff and changed code review passed Reviewed all 10 changed files’ diff hunks
Build and tests not run No execution performed
Negative control not run No test modification performed

Findings

Blocking

None.

Non-blocking

  • Consider adding coverage for length == -1 and iteration across the provider’s 32-unit chunk boundary. The added test exercises a known-length short string and does not cover these paths (core/libs/prx/libSceIcu/tests/UTextAccess.cpp:28).

Sources

Reviewed the prepared diff and the implementation at the pinned head, including UText.cpp for the existing close protocol and Status.hpp for status handling.

Not verified

Build and test results reported by the author were not rerun. PS5 behavior and guest-heap allocation were not tested. The full text of LegacyExports.cpp and LegacyExports.hpp was not read; their changed removals were reviewed in the diff. All 10 changed files were listed in the review manifest, and their changed hunks were inspected.

To get this to a good state

Nothing is required. Optional: add tests for null-terminated input and chunk-boundary iteration.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5992344440 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23900#pullrequestreview-5992344440). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T12:02:30Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected implementation has no verified blocking defect; runtime checks were not run in this review. ## What I ran Inspected the prepared diff and relevant code at head `6c44b93a33b3e709d591aad96b1b0086d18996e6` using `repo_read.py` reader tools. No build or tests were run. The author reports Windows tests and checks in the PR description; those results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code review | passed | Reviewed all 10 changed files’ diff hunks | | Build and tests | not run | No execution performed | | Negative control | not run | No test modification performed | ## Findings ### Blocking None. ### Non-blocking - Consider adding coverage for `length == -1` and iteration across the provider’s 32-unit chunk boundary. The added test exercises a known-length short string and does not cover these paths (`core/libs/prx/libSceIcu/tests/UTextAccess.cpp:28`). ## Sources Reviewed the prepared diff and the implementation at the pinned head, including `UText.cpp` for the existing close protocol and `Status.hpp` for status handling. ## Not verified Build and test results reported by the author were not rerun. PS5 behavior and guest-heap allocation were not tested. The full text of `LegacyExports.cpp` and `LegacyExports.hpp` was not read; their changed removals were reviewed in the diff. All 10 changed files were listed in the review manifest, and their changed hunks were inspected. ## To get this to a good state Nothing is required. Optional: add tests for null-terminated input and chunk-boundary iteration.
MarcZX10 commented 2026-11-20 15:21:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:21:01Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: handle empty and boundary positions safely in utext_extract and the UChar provider access routine.

What I ran

Read the prepared diff and all changed files listed as included in the review manifest. Inspected UText.cpp, Configuration.cpp, and TerminateBuffer.cpp for close, allocation, and extraction behavior. No build or tests were run; the test results in the PR description are author-reported.

Results

Check Result Note
Source review failed Two boundary cases can read outside the string.
Build and tests not run Reported results were not independently verified.

Findings

Blocking

  • core/libs/prx/libSceIcu/UTextAccess.cpp:209: StringExtract calls StringAccess and then reads text->chunkContents and text->chunkOffset. For an empty string, or when start is beyond the known string length, StringAccess can return unavailable without setting a valid offset; extraction then reads string[0] or string[length]. Clamp start to the known length and return an empty extraction before dereferencing when the requested range has no text.
  • core/libs/prx/libSceIcu/UTextAccess.cpp:163: For a NUL-terminated input shorter than 32 units where a query starts beyond its terminator, StringAccess can scan past the terminator and read beyond the input. It starts at the cached chunk limit and scans up to index + 32 without first establishing that index is within the string. Find/cache the terminator before reading toward an out-of-range index, then clamp the requested index to the discovered length.

Non-blocking

None.

Not verified

  • Build, test suite, and console behavior were not run or independently confirmed; the PR description reports those results.
  • review/files.json was not available through the review reader. The review folder lists ten changed files, all marked included, and each changed file's added lines were read.
  • No commit-pinned source links are included because this review interface did not provide a permalink operation.

To get this to a good state

Fix both out-of-range paths and add regression cases for empty text, start beyond a known length, and a NUL-terminated string queried beyond its terminator. Run the new test and the ICU suite on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5995024304 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23900#pullrequestreview-5995024304). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T15:21:01Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: handle empty and boundary positions safely in `utext_extract` and the UChar provider access routine. ## What I ran Read the prepared diff and all changed files listed as included in the review manifest. Inspected `UText.cpp`, `Configuration.cpp`, and `TerminateBuffer.cpp` for close, allocation, and extraction behavior. No build or tests were run; the test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Two boundary cases can read outside the string. | | Build and tests | not run | Reported results were not independently verified. | ## Findings ### Blocking - `core/libs/prx/libSceIcu/UTextAccess.cpp:209`: `StringExtract` calls `StringAccess` and then reads `text->chunkContents` and `text->chunkOffset`. For an empty string, or when `start` is beyond the known string length, `StringAccess` can return unavailable without setting a valid offset; extraction then reads `string[0]` or `string[length]`. Clamp `start` to the known length and return an empty extraction before dereferencing when the requested range has no text. - `core/libs/prx/libSceIcu/UTextAccess.cpp:163`: For a NUL-terminated input shorter than 32 units where a query starts beyond its terminator, `StringAccess` can scan past the terminator and read beyond the input. It starts at the cached chunk limit and scans up to `index + 32` without first establishing that `index` is within the string. Find/cache the terminator before reading toward an out-of-range index, then clamp the requested index to the discovered length. ### Non-blocking None. ## Not verified - Build, test suite, and console behavior were not run or independently confirmed; the PR description reports those results. - `review/files.json` was not available through the review reader. The review folder lists ten changed files, all marked included, and each changed file's added lines were read. - No commit-pinned source links are included because this review interface did not provide a permalink operation. ## To get this to a good state Fix both out-of-range paths and add regression cases for empty text, `start` beyond a known length, and a NUL-terminated string queried beyond its terminator. Run the new test and the ICU suite on the updated head.
MarcZX10 commented 2026-11-20 16:34:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T16:34:09Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: keep the existing close protocol valid when a UText is reopened after allocating provider extra space.

What I ran

Reviewed head 62f9fd9d3437969ff6549e3670804a4e28311e31 from the prepared diff and pinned reader. No commands or tests were run in this review.

Results

Check Result Note
Source review failed Reopen path can invalidate close state
Tests not run Author reports Windows and ICU suite passes

Findings

Blocking

  • core/libs/prx/libSceIcu/UTextAccess.cpp:310 — When reopening a caller supplied UText with ExtraHeapAllocated set and a larger extraSpace, setup frees pExtra but does not clear ExtraHeapAllocated before attempting the replacement allocation. If allocation fails, utext_close later sees the stale flag and releases the already-freed pointer again. Clear the flag immediately after releasing the old extra storage, including on allocation failure.

Non-blocking

None.

Not verified

The full text of all changed files was included and read: core/libs/prx/libSceIcu/CMakeLists.txt, Export.cpp, LegacyExports.cpp, UTextAccess.cpp, UTextAccess.hpp, include/InventoryExports.hpp, include/LegacyExports.hpp, libSceIcu.hpp, tests/UTextAccess.cpp, and docs/dev/debt/changes/feat-libsceicu-utext.md. The prepared diff and manifest were read. files.json was not available in the review folder, so excluded files could not be confirmed from it; the reader file list showed all listed changed files included. Tests reported by the author were not rerun.

To get this to a good state

Clear ExtraHeapAllocated when releasing the prior pExtra, and rerun the ICU tests, including a forced allocation-failure case for reopening a supplied UText.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5996041023 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23900#pullrequestreview-5996041023). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T16:34:09Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: keep the existing close protocol valid when a UText is reopened after allocating provider extra space. ## What I ran Reviewed head `62f9fd9d3437969ff6549e3670804a4e28311e31` from the prepared diff and pinned reader. No commands or tests were run in this review. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Reopen path can invalidate close state | | Tests | not run | Author reports Windows and ICU suite passes | ## Findings ### Blocking - `core/libs/prx/libSceIcu/UTextAccess.cpp:310` — When reopening a caller supplied UText with `ExtraHeapAllocated` set and a larger `extraSpace`, setup frees `pExtra` but does not clear `ExtraHeapAllocated` before attempting the replacement allocation. If allocation fails, `utext_close` later sees the stale flag and releases the already-freed pointer again. Clear the flag immediately after releasing the old extra storage, including on allocation failure. ### Non-blocking None. ## Not verified The full text of all changed files was included and read: `core/libs/prx/libSceIcu/CMakeLists.txt`, `Export.cpp`, `LegacyExports.cpp`, `UTextAccess.cpp`, `UTextAccess.hpp`, `include/InventoryExports.hpp`, `include/LegacyExports.hpp`, `libSceIcu.hpp`, `tests/UTextAccess.cpp`, and `docs/dev/debt/changes/feat-libsceicu-utext.md`. The prepared diff and manifest were read. `files.json` was not available in the review folder, so excluded files could not be confirmed from it; the reader file list showed all listed changed files included. Tests reported by the author were not rerun. ## To get this to a good state Clear `ExtraHeapAllocated` when releasing the prior `pExtra`, and rerun the ICU tests, including a forced allocation-failure case for reopening a supplied UText.
ligmaSec commented 2026-12-03 11:10:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:10:43Z.

Review: COMMENTED


Built the submitted UText implementation against bundled ICU and ran the exact UTextAccess fixture on Linux. It passed extraction, cursor, and length checks, including starts at and beyond the 32-unit chunk boundary.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6168581270 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23900#pullrequestreview-6168581270). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T11:10:43Z. **Review:** COMMENTED --- Built the submitted UText implementation against bundled ICU and ran the exact `UTextAccess` fixture on Linux. It passed extraction, cursor, and length checks, including starts at and beyond the 32-unit chunk boundary. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/23900:upstream-pr/23900'
git switch 'upstream-pr/23900'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/23900'
git switch 'upstream-pr/23900'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/23900'
git switch 'upstream-pr/23900'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/23900'
git switch 'main'
git merge --squash 'upstream-pr/23900'
git switch 'main'
git merge --ff-only 'upstream-pr/23900'
git switch 'main'
git merge 'upstream-pr/23900'
git push origin 'main'
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!23900
No description provided.