feat(libSceIcu): give eight usearch exports their ICU 68.2 signatures and early returns #23819

Merged
ToRaNek merged 1 commit from upstream-pr/23819 into main 2026-11-19 20:12:31 +00:00
ToRaNek commented 2026-11-19 17:54:33 +00:00 (Migrated from github.com)

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


What

Eight usearch exports of libSceIcu were parameterless int placeholders in RecoveredInventory.cpp that threw on every call: usearch_getCollator, usearch_getMatchedLength, usearch_next, usearch_reset, usearch_setAttribute, usearch_setOffset, usearch_setPattern and usearch_setText. They now have their ICU 68.2 prototypes and the early returns of usearch.cpp, next to usearch_open in StringSearch.cpp, the way #17265 did it for 70 other recovered exports. No UStringSearch object can exist yet (usearch_open throws on a valid call), so every path that reads or writes one still throws NotImplemented_nid_no_patch.

What each one does before it needs the object, with the lines of usearch.cpp at that commit:

Export Returns without the object Lines
usearch_getCollator null search: NULL 3067-3073
usearch_getMatchedLength null search: USEARCH_DONE (-1) 2937-2944
usearch_reset null search: nothing 3386-3442
usearch_next failing status or null search: USEARCH_DONE, status untouched 3190-3296
usearch_setOffset failing status or null search: nothing, status untouched 2806-2821
usearch_setAttribute failing status or null search: skips the attribute; with a search, an attribute outside 0..2 sets U_ILLEGAL_ARGUMENT_ERROR without reading the object; then value USEARCH_ATTRIBUTE_VALUE_COUNT (5) sets U_ILLEGAL_ARGUMENT_ERROR whatever the status and the search were 2835-2865
usearch_setPattern failing status: nothing; null search or null pattern, length 0, or length -1 with an empty pattern: U_ILLEGAL_ARGUMENT_ERROR 3075-3097
usearch_setText failing status: nothing; null search, null text, length below -1 or length 0: U_ILLEGAL_ARGUMENT_ERROR 2972-3001

Two details follow the source rather than the usual pattern:

  • usearch_setAttribute tests value == USEARCH_ATTRIBUTE_VALUE_COUNT after its if (U_SUCCESS(*status) && strsrch) block, so that value overwrites an already failing status and is reported for a null search too.
  • usearch_setPattern with length -1 calls u_strlen and rejects a length of 0. Only the first code unit is read here: an empty pattern is rejected, any other one goes on to the object and throws. usearch_setText has no such check: length -1 with an empty text reaches the object, so it throws.

The guest UErrorCode and the first pattern unit are read and written through the file's existing GuestCopyIn_nid_no_patch / GuestCopyOut_nid_no_patch helpers, which keep errno. A null UErrorCode throws, as for usearch_open: the console dereferences it.

Debt: the ICU string search exports entry now names the nine exports. The recovered inventory exports entry goes from 47 to 39 placeholders left; tools/debt_fold.py --check refuses two fragments that change the same entry and asks to merge them, so that count is edited in the pending feat-libsceicu-field-position-iterator.md fragment.

Tested

Windows 11 IoT Enterprise LTSC 2024 (10.0.26100), WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, base main 9d5f50bdf0. Not run on a console; the console behaviour of these exports is unverified, as the debt entry says.

  • guest_icu_recovered_signatures passes. tests/StringSearch.cpp gains a UsearchObject group: static_asserts on the eight prototypes; the null-search results; seven failing and four non-failing status values against a null and a non-null search (status unchanged where ICU leaves it, U_ILLEGAL_ARGUMENT_ERROR where ICU sets it, a throw where the object is needed, the fake object's bytes unchanged); a null status; and guest pointers (an unreadable status, a read-only status that must not be written on the early returns and throws when a write is due, an unreadable pattern with length -1), with errno kept.
  • Red: on main the placeholders are int(), so the new checks cannot compile against them (by construction, not built). Five one-line mutations of the new code each fail the test, then it passes again with the code restored: a null search returning 0 from usearch_getMatchedLength; the USEARCH_ATTRIBUTE_VALUE_COUNT check removed; the empty pattern at length -1 not rejected; usearch_setText accepting a length below -1; usearch_setAttribute throwing on an attribute outside 0..2.
  • ctest -R icu: 76 of 76 pass.
  • python tools/check_conventions.py --base origin/main and python tools/debt_fold.py --check pass.
  • python tools/pr_overlap.py --names over the eight names: each is a stub on main and no open PR adds or edits it. --branch could not compare six open PRs that conflict with main on the recovered inventory files (#18210, #19635, #19645, #19670, #19720, #23196); compared by hand, none of them touches a usearch export or the string search debt entry.

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 (see AGENTS.md)
  • 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 (attach them to this PR)
  • 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:5400168928 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23819). Originally posted by [ToRaNek](https://github.com/ToRaNek) on 2026-11-19T17:54:33Z. --- ### What Eight `usearch` exports of libSceIcu were parameterless `int` placeholders in `RecoveredInventory.cpp` that threw on every call: `usearch_getCollator`, `usearch_getMatchedLength`, `usearch_next`, `usearch_reset`, `usearch_setAttribute`, `usearch_setOffset`, `usearch_setPattern` and `usearch_setText`. They now have their ICU 68.2 prototypes and the early returns of [usearch.cpp](https://github.com/unicode-org/icu/blob/84e1f26ea77152936e70d53178a816dbfbf69989/icu4c/source/i18n/usearch.cpp), next to `usearch_open` in `StringSearch.cpp`, the way #17265 did it for 70 other recovered exports. No `UStringSearch` object can exist yet (`usearch_open` throws on a valid call), so every path that reads or writes one still throws `NotImplemented_nid_no_patch`. What each one does before it needs the object, with the lines of usearch.cpp at that commit: | Export | Returns without the object | Lines | |---|---|---| | `usearch_getCollator` | null search: `NULL` | 3067-3073 | | `usearch_getMatchedLength` | null search: `USEARCH_DONE` (-1) | 2937-2944 | | `usearch_reset` | null search: nothing | 3386-3442 | | `usearch_next` | failing status or null search: `USEARCH_DONE`, status untouched | 3190-3296 | | `usearch_setOffset` | failing status or null search: nothing, status untouched | 2806-2821 | | `usearch_setAttribute` | failing status or null search: skips the attribute; with a search, an attribute outside 0..2 sets `U_ILLEGAL_ARGUMENT_ERROR` without reading the object; then value `USEARCH_ATTRIBUTE_VALUE_COUNT` (5) sets `U_ILLEGAL_ARGUMENT_ERROR` whatever the status and the search were | 2835-2865 | | `usearch_setPattern` | failing status: nothing; null search or null pattern, length 0, or length -1 with an empty pattern: `U_ILLEGAL_ARGUMENT_ERROR` | 3075-3097 | | `usearch_setText` | failing status: nothing; null search, null text, length below -1 or length 0: `U_ILLEGAL_ARGUMENT_ERROR` | 2972-3001 | Two details follow the source rather than the usual pattern: - `usearch_setAttribute` tests `value == USEARCH_ATTRIBUTE_VALUE_COUNT` after its `if (U_SUCCESS(*status) && strsrch)` block, so that value overwrites an already failing status and is reported for a null search too. - `usearch_setPattern` with length -1 calls `u_strlen` and rejects a length of 0. Only the first code unit is read here: an empty pattern is rejected, any other one goes on to the object and throws. `usearch_setText` has no such check: length -1 with an empty text reaches the object, so it throws. The guest `UErrorCode` and the first pattern unit are read and written through the file's existing `GuestCopyIn_nid_no_patch` / `GuestCopyOut_nid_no_patch` helpers, which keep `errno`. A null `UErrorCode` throws, as for `usearch_open`: the console dereferences it. Debt: the `ICU string search exports` entry now names the nine exports. The `recovered inventory exports` entry goes from 47 to 39 placeholders left; `tools/debt_fold.py --check` refuses two fragments that change the same entry and asks to merge them, so that count is edited in the pending `feat-libsceicu-field-position-iterator.md` fragment. ### Tested Windows 11 IoT Enterprise LTSC 2024 (10.0.26100), WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, base `main` `9d5f50bdf0`. Not run on a console; the console behaviour of these exports is unverified, as the debt entry says. - `guest_icu_recovered_signatures` passes. `tests/StringSearch.cpp` gains a `UsearchObject` group: `static_assert`s on the eight prototypes; the null-search results; seven failing and four non-failing status values against a null and a non-null search (status unchanged where ICU leaves it, `U_ILLEGAL_ARGUMENT_ERROR` where ICU sets it, a throw where the object is needed, the fake object's bytes unchanged); a null status; and guest pointers (an unreadable status, a read-only status that must not be written on the early returns and throws when a write is due, an unreadable pattern with length -1), with `errno` kept. - Red: on `main` the placeholders are `int()`, so the new checks cannot compile against them (by construction, not built). Five one-line mutations of the new code each fail the test, then it passes again with the code restored: a null search returning 0 from `usearch_getMatchedLength`; the `USEARCH_ATTRIBUTE_VALUE_COUNT` check removed; the empty pattern at length -1 not rejected; `usearch_setText` accepting a length below -1; `usearch_setAttribute` throwing on an attribute outside 0..2. - `ctest -R icu`: 76 of 76 pass. - `python tools/check_conventions.py --base origin/main` and `python tools/debt_fold.py --check` pass. - `python tools/pr_overlap.py --names` over the eight names: each is a stub on `main` and no open PR adds or edits it. `--branch` could not compare six open PRs that conflict with `main` on the recovered inventory files (#18210, #19635, #19645, #19670, #19720, #23196); compared by hand, none of them touches a `usearch` export or the string search debt entry. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [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 18:17:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T18:17:56Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 72d2b41c59:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_recovered_signatures_tests built cleanly.
  • CTest (guest_icu_recovered_signatures):
    1/1 Test #3992: guest_icu_recovered_signatures ...   Passed    0.06 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/RecoveredInventory.cpp, core/libs/prx/libSceIcu/RecoveredInventory.hpp, core/libs/prx/libSceIcu/RecoveredSignatures.hpp, core/libs/prx/libSceIcu/StringSearch.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified recovered signatures in RecoveredSignatures.hpp match ICU 68.2 and POSIX/VABI calling conventions
    • Verified null/error propagation and Icu::RequireStatus/GuestCopy checks in usearch_getCollator, usearch_getMatchedLength, usearch_next, usearch_reset, usearch_setAttribute, usearch_setOffset, usearch_setPattern, and usearch_setText
    • Verified attribute bounds and AttributeValueCount handling in usearch_setAttribute against upstream ICU 68.2 usearch.cpp early returns
    • Verified technical debt fragments in docs/dev/debt/changes/ follow repository guidelines and no code comments were introduced
    • Verified tests in tests/StringSearch.cpp exercise status error branches, null pointers, read-only guest memory pages, and NotImplemented_nid_no_patch throws

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5980772617 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23819#pullrequestreview-5980772617). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T18:17:56Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `72d2b41c59`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_recovered_signatures_tests` built cleanly. - **CTest** (`guest_icu_recovered_signatures`): ``` 1/1 Test #3992: guest_icu_recovered_signatures ... Passed 0.06 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/RecoveredInventory.cpp`, `core/libs/prx/libSceIcu/RecoveredInventory.hpp`, `core/libs/prx/libSceIcu/RecoveredSignatures.hpp`, `core/libs/prx/libSceIcu/StringSearch.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified recovered signatures in RecoveredSignatures.hpp match ICU 68.2 and POSIX/VABI calling conventions - Verified null/error propagation and Icu::RequireStatus/GuestCopy checks in usearch_getCollator, usearch_getMatchedLength, usearch_next, usearch_reset, usearch_setAttribute, usearch_setOffset, usearch_setPattern, and usearch_setText - Verified attribute bounds and AttributeValueCount handling in usearch_setAttribute against upstream ICU 68.2 usearch.cpp early returns - Verified technical debt fragments in docs/dev/debt/changes/ follow repository guidelines and no code comments were introduced - Verified tests in tests/StringSearch.cpp exercise status error branches, null pointers, read-only guest memory pages, and NotImplemented_nid_no_patch throws Looks Good To Me
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!23819
No description provided.