feat(libSceIcu): search UTF-16 strings through guest copies #25528

Merged
pinewhite merged 2 commits from upstream-pr/25528 into main 2026-11-25 10:05:21 +00:00
pinewhite commented 2026-11-22 07:27:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pinewhite on 2026-11-22T07:27:31Z.


What

u_strFindFirst and u_strFindLast now copy both operands in from guest memory and run the ICU search on the copies, instead of passing guest addresses straight to the linked ustring.cpp routines and pre-measuring a NUL-terminated operand with a local loop that threw NotImplemented_nid_no_patch once the length no longer fit INT32_MAX.

  • Both operands are read through GuestCopyIn in page-sized chunks; a -1 length stops after the terminator, which stays in the copy so ICU still sees a NUL-terminated operand and takes the same path it did before.
  • The result is translated back to the guest string: text + (found - copy), and nullptr when ICU finds nothing.
  • The null needle, null text, needleCount below -1, count below -1 and empty-needle shortcuts keep ICU's order and results, and an empty needle still returns the text without reading it.
  • An unreadable operand throws std::invalid_argument instead of faulting on the guest address.
  • The local length helper and its NotImplemented_nid_no_patch branch are gone, so tools/progress.py counts both exports.

python3 tools/progress.py --module libSceIcu: done 321 -> 323 of 2766 (11.61% -> 11.68%). u_strFindFirst and u_strFindLast no longer reach NotImplemented_nid_no_patch; nothing else moved.

Tested

Host proof on Ubuntu 24.04 aarch64, g++ 13.3.0, -std=c++20 -O1 -ffunction-sections -fdata-sections -Icore/libs, linked with -Wl,--gc-sections:

  • core/libs/prx/libSceIcu/Utf16Search.cpp compiled by hand into a runner. Shimmed seams: GuestCopyIn_nid_no_patch (memcpy over host memory plus a registry of inaccessible ranges), u_strFindFirst/u_strFindLast forwarded to u_strFindFirst_74/u_strFindLast_74 of host ICU 74, GuestArenaBeginHostWrite_nid_postfix, GuestArenaEndHostWrite_nid_postfix and NotImplementedAt_nid_no_patch.
  • Contract cases from core/libs/tests/GuestIcuSearch.cpp (Substrings), the new long-operand cases, and the new mapped cases repeated over mmap pages: text and needle crossing a page boundary, a needle ending exactly at the boundary, a surrogate pair inside the mapped text, a count that excludes the pair, and a read-only first page. All pass.
  • Differential against host ICU 74: 60,000 randomized cases (texts and needles with surrogates and embedded NULs, counts and needle counts of -1 and counted variants, first and last) return the same offset or nullptr.
  • Pre-change body with an unreadable operand: SIGSEGV, exit 139. New body: std::invalid_argument, exit 0.

Not run: the CMake/ctest guest suites (no PS5 toolchain, ICU 78.1 build or emulator run in this environment), Windows direct-memory behaviour, and any console comparison.

Note: PR #22390 edits the include block at the top of Utf16Search.cpp. This branch adds one ICU include there, so the overlap is a rebase on merge, not a functional conflict.

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:5436878003 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25528). Originally posted by [pinewhite](https://github.com/pinewhite) on 2026-11-22T07:27:31Z. --- ### What `u_strFindFirst` and `u_strFindLast` now copy both operands in from guest memory and run the ICU search on the copies, instead of passing guest addresses straight to the linked `ustring.cpp` routines and pre-measuring a NUL-terminated operand with a local loop that threw `NotImplemented_nid_no_patch` once the length no longer fit `INT32_MAX`. - Both operands are read through `GuestCopyIn` in page-sized chunks; a `-1` length stops after the terminator, which stays in the copy so ICU still sees a NUL-terminated operand and takes the same path it did before. - The result is translated back to the guest string: `text + (found - copy)`, and `nullptr` when ICU finds nothing. - The null needle, null text, `needleCount` below `-1`, `count` below `-1` and empty-needle shortcuts keep ICU's order and results, and an empty needle still returns the text without reading it. - An unreadable operand throws `std::invalid_argument` instead of faulting on the guest address. - The local length helper and its `NotImplemented_nid_no_patch` branch are gone, so `tools/progress.py` counts both exports. `python3 tools/progress.py --module libSceIcu`: done 321 -> 323 of 2766 (11.61% -> 11.68%). `u_strFindFirst` and `u_strFindLast` no longer reach `NotImplemented_nid_no_patch`; nothing else moved. ### Tested Host proof on Ubuntu 24.04 aarch64, g++ 13.3.0, `-std=c++20 -O1 -ffunction-sections -fdata-sections -Icore/libs`, linked with `-Wl,--gc-sections`: - `core/libs/prx/libSceIcu/Utf16Search.cpp` compiled by hand into a runner. Shimmed seams: `GuestCopyIn_nid_no_patch` (memcpy over host memory plus a registry of inaccessible ranges), `u_strFindFirst`/`u_strFindLast` forwarded to `u_strFindFirst_74`/`u_strFindLast_74` of host ICU 74, `GuestArenaBeginHostWrite_nid_postfix`, `GuestArenaEndHostWrite_nid_postfix` and `NotImplementedAt_nid_no_patch`. - Contract cases from `core/libs/tests/GuestIcuSearch.cpp` (`Substrings`), the new long-operand cases, and the new mapped cases repeated over `mmap` pages: text and needle crossing a page boundary, a needle ending exactly at the boundary, a surrogate pair inside the mapped text, a count that excludes the pair, and a read-only first page. All pass. - Differential against host ICU 74: 60,000 randomized cases (texts and needles with surrogates and embedded NULs, counts and needle counts of `-1` and counted variants, first and last) return the same offset or `nullptr`. - Pre-change body with an unreadable operand: SIGSEGV, exit 139. New body: `std::invalid_argument`, exit 0. Not run: the CMake/ctest guest suites (no PS5 toolchain, ICU 78.1 build or emulator run in this environment), Windows direct-memory behaviour, and any console comparison. Note: [PR #22390](https://github.com/boykopovar/AnyPS5/pull/22390) edits the include block at the top of `Utf16Search.cpp`. This branch adds one ICU include there, so the overlap is a rebase on merge, not a functional conflict. ### 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-22 07:28:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T07:28:34Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_utf16_search_tests built cleanly.
  • CTest (guest_icu_utf16_search):
    1/1 Test #4085: guest_icu_utf16_search ...........   Passed    0.13 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Utf16Search.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4085: guest_icu_utf16_search ...........   Passed    0.13 sec
    100% tests passed, 0 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libSceIcu/Utf16Search.cpp: ReadOperand page-aligned chunking and limit bounds logic with count >= 0 and count == -1
    • core/libs/prx/libSceIcu/Utf16Search.cpp: std::memcpy and char16_t NUL scanning alignment and termination logic
    • core/libs/prx/libSceIcu/Utf16Search.cpp: Find pointer arithmetic and offset translation back to guest pointers (text + (found - units.data()))
    • core/libs/prx/libSceIcu/Utf16Search.cpp: Handling of needleCount < -1, count < -1, null needle, null text, and subLength == 0 shortcuts matching ICU conventions
    • core/libs/tests/GuestIcuSearch.cpp: Direct memory mapping, mprotect, and test verification across page boundaries
    • docs/dev/debt/changes/feat-icu-string-utf16-find.md: Debt fragment formatting, naming, and AGENTS.md conventions

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6011049953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25528#pullrequestreview-6011049953). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-22T07:28:34Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `d20a820d2e`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_utf16_search_tests` built cleanly. - **CTest** (`guest_icu_utf16_search`): ``` 1/1 Test #4085: guest_icu_utf16_search ........... Passed 0.13 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Utf16Search.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #4085: guest_icu_utf16_search ........... Passed 0.13 sec 100% tests passed, 0 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libSceIcu/Utf16Search.cpp: ReadOperand page-aligned chunking and limit bounds logic with count >= 0 and count == -1 - core/libs/prx/libSceIcu/Utf16Search.cpp: std::memcpy and char16_t NUL scanning alignment and termination logic - core/libs/prx/libSceIcu/Utf16Search.cpp: Find pointer arithmetic and offset translation back to guest pointers (text + (found - units.data())) - core/libs/prx/libSceIcu/Utf16Search.cpp: Handling of needleCount < -1, count < -1, null needle, null text, and subLength == 0 shortcuts matching ICU conventions - core/libs/tests/GuestIcuSearch.cpp: Direct memory mapping, mprotect, and test verification across page boundaries - docs/dev/debt/changes/feat-icu-string-utf16-find.md: Debt fragment formatting, naming, and AGENTS.md conventions Looks Good To Me
MarcZX10 commented 2026-11-22 07:42:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T07:42:44Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: preserve UTF-16 code unit alignment when copying operands across page boundaries.

What I ran

  • Reviewed head d20a820d2e493b3da35b583a7f0e6c8195bfbfc1 using repo_read.py.
  • No tests or builds run; the PR description reports a host proof and explicitly says the CMake/ctest guest suites were not run.

Results

Check Result Note
Source review failed Odd-address copies can shift UTF-16 units
Tests/build not run Author-reported host proof only

Findings

Blocking

  • core/libs/prx/libSceIcu/Utf16Search.cpp:29 — For an operand whose address is not 2-byte aligned, a page boundary can split a UTF-16 code unit. The chunk length is chosen to end exactly at the 4 KiB boundary, then the next chunk starts at the next page, so scanning at offsets 0, 2, 4, ... in ReadOperand resumes on the wrong byte parity. This can miss the terminator or assemble different code units, leading to incorrect search results or an unreadable-memory exception even when the full UTF-16 operand is mapped. Preserve the operand’s code-unit alignment across chunks, for example by making each non-final chunk length even.

Non-blocking

None.

Not verified

  • The report’s host proof, randomized differential cases, and pre-change comparison were not run during this review.
  • The CMake/ctest guest suites, Windows direct-memory behavior, and console behavior were not run, as also stated in the PR description.
  • Read changed files: core/libs/prx/libSceIcu/Utf16Search.cpp, core/libs/tests/GuestIcuSearch.cpp, and docs/dev/debt/changes/feat-icu-string-utf16-find.md. All three files listed in the manifest were read; no changed files were excluded.

To get this to a good state

  • Keep chunk boundaries aligned to UTF-16 code units for odd-address operands, and add a regression case with an operand crossing a page boundary at odd byte alignment. Then rerun the focused host proof and guest tests on the updated head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:6011090664 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25528#pullrequestreview-6011090664). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T07:42:44Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: preserve UTF-16 code unit alignment when copying operands across page boundaries. ## What I ran - Reviewed head `d20a820d2e493b3da35b583a7f0e6c8195bfbfc1` using `repo_read.py`. - No tests or builds run; the PR description reports a host proof and explicitly says the CMake/ctest guest suites were not run. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Odd-address copies can shift UTF-16 units | | Tests/build | not run | Author-reported host proof only | ## Findings ### Blocking - `core/libs/prx/libSceIcu/Utf16Search.cpp:29` — For an operand whose address is not 2-byte aligned, a page boundary can split a UTF-16 code unit. The chunk length is chosen to end exactly at the 4 KiB boundary, then the next chunk starts at the next page, so scanning at offsets `0, 2, 4, ...` in `ReadOperand` resumes on the wrong byte parity. This can miss the terminator or assemble different code units, leading to incorrect search results or an unreadable-memory exception even when the full UTF-16 operand is mapped. Preserve the operand’s code-unit alignment across chunks, for example by making each non-final chunk length even. ### Non-blocking None. ## Not verified - The report’s host proof, randomized differential cases, and pre-change comparison were not run during this review. - The CMake/ctest guest suites, Windows direct-memory behavior, and console behavior were not run, as also stated in the PR description. - Read changed files: `core/libs/prx/libSceIcu/Utf16Search.cpp`, `core/libs/tests/GuestIcuSearch.cpp`, and `docs/dev/debt/changes/feat-icu-string-utf16-find.md`. All three files listed in the manifest were read; no changed files were excluded. ## To get this to a good state - Keep chunk boundaries aligned to UTF-16 code units for odd-address operands, and add a regression case with an operand crossing a page boundary at odd byte alignment. Then rerun the focused host proof and guest tests on the updated head.
PrivacyOnion commented 2026-11-22 08:30:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T08:30:51Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 1476b1e39a:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_utf16_search_tests built cleanly.
  • CTest (guest_icu_utf16_search):
    1/1 Test #4087: guest_icu_utf16_search ...........   Passed    0.34 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Utf16Search.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4087: guest_icu_utf16_search ...........   Passed    0.27 sec
    100% tests passed, 0 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified ReadOperand chunking and bounds logic in core/libs/prx/libSceIcu/Utf16Search.cpp:21-55 for count >= 0 and count == -1
    • Verified operand alignment behavior and addressed contributor MarcZX10's review note: UTF-16 code units (char16_t) are 2-byte aligned in valid strings and (address + offset) % Chunk preserves byte parity at 4096-byte (even) page boundaries
    • Checked u_strFindFirst and u_strFindLast shortcuts in core/libs/prx/libSceIcu/Utf16Search.cpp:138-148 for null operands, negative counts (< -1), and empty needle return values against ICU ustring.cpp conventions
    • Verified guest-to-host translation math in Find (text + (found - units.data())) and std::invalid_argument exception throwing on unreadable guest memory
    • Audited technical debt fragment docs/dev/debt/changes/feat-icu-string-utf16-find.md and AGENTS.md compliance for code comments, conventions, and test coverage in core/libs/tests/GuestIcuSearch.cpp

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6011241169 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25528#pullrequestreview-6011241169). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-22T08:30:51Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `1476b1e39a`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_utf16_search_tests` built cleanly. - **CTest** (`guest_icu_utf16_search`): ``` 1/1 Test #4087: guest_icu_utf16_search ........... Passed 0.34 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Utf16Search.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #4087: guest_icu_utf16_search ........... Passed 0.27 sec 100% tests passed, 0 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified ReadOperand chunking and bounds logic in core/libs/prx/libSceIcu/Utf16Search.cpp:21-55 for count >= 0 and count == -1 - Verified operand alignment behavior and addressed contributor MarcZX10's review note: UTF-16 code units (char16_t) are 2-byte aligned in valid strings and (address + offset) % Chunk preserves byte parity at 4096-byte (even) page boundaries - Checked u_strFindFirst and u_strFindLast shortcuts in core/libs/prx/libSceIcu/Utf16Search.cpp:138-148 for null operands, negative counts (< -1), and empty needle return values against ICU ustring.cpp conventions - Verified guest-to-host translation math in Find (text + (found - units.data())) and std::invalid_argument exception throwing on unreadable guest memory - Audited technical debt fragment docs/dev/debt/changes/feat-icu-string-utf16-find.md and AGENTS.md compliance for code comments, conventions, and test coverage in core/libs/tests/GuestIcuSearch.cpp Looks Good To Me
MarcZX10 commented 2026-11-22 08:34:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T08:34:50Z.

Review: APPROVED


Reviewed — looks good

The changed search wrappers and added guest tests were reviewed at head 1476b1e39a9db11cc1d870558c63bddacea6fb5d; no verified blocking defects were found, and the author reports host-side checks that I did not run.

What I ran

No commands were run. I read the prepared diff, manifest, description, commit list, both included changed source files, and the added debt note. Repository context was inspected through the pinned reader repo_read.py.

Results

Check Result Note
Changed implementation review passed Read in full
Added guest test review passed Read relevant sections
Host and guest checks not run Host results are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the reported host proof, CMake/ctest guest suites, or a console comparison. The full repository test harness and CI results were not inspected. The files excluded from the prepared diff by rule were not listed in the supplied bundle; their contents were not reviewed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6011264085 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25528#pullrequestreview-6011264085). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T08:34:50Z. **Review:** APPROVED --- # Reviewed — looks good The changed search wrappers and added guest tests were reviewed at head `1476b1e39a9db11cc1d870558c63bddacea6fb5d`; no verified blocking defects were found, and the author reports host-side checks that I did not run. ## What I ran No commands were run. I read the prepared diff, manifest, description, commit list, both included changed source files, and the added debt note. Repository context was inspected through the pinned reader `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Changed implementation review | passed | Read in full | | Added guest test review | passed | Read relevant sections | | Host and guest checks | not run | Host results are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the reported host proof, CMake/ctest guest suites, or a console comparison. The full repository test harness and CI results were not inspected. The files excluded from the prepared diff by rule were not listed in the supplied bundle; their contents were not reviewed. ## To get this to a good state Nothing is required.
throny commented 2026-11-22 16:56:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T16:56:53Z.

Review: COMMENTED


Review: ⚠️ the search wrappers match ICU 78.1, but the tests also pass on main

Basis: code read against 3rdparty/icu 049e0d6a42 (ustring.cpp u_strFindFirst/u_strFindLast) · head 1476b1e39a

Checked

  • The shortcut order matches ICU: a null needle or count < -1 returns the text, null text returns null, and an empty needle returns the text before the text is read. A -1 operand keeps its NUL in the copy, and a counted operand copies exactly count units, so ICU sees the same window, including the surrogate-boundary checks.
  • Utf16Search.cpp:65 maps the match back to the guest pointer. -1 operands are read in chunks that end on a page boundary, stopping at the NUL.
  • The earlier odd-address alignment concern doesn't hold: parity is relative to the operand, and the scan restarts at offset & ~1.

Findings

  1. The negative control posted on the PR shows guest_icu_utf16_search Passed with Utf16Search.cpp reverted to main, so the new cases don't pin the change. The behaviour that changes is that an unreadable operand throws instead of faulting. Please add a case with an unmapped (PROT_NONE) operand that expects a throw, and one with unreadable text and an empty needle that expects the text back.
  2. Utf16Search.cpp:24-33: a counted operand is now copied in full up front. A guest that passes a count larger than its mapping, where the match comes first, used to succeed because ICU stops at the match; it now throws. A count near INT32_MAX also grows a host buffer toward 4 GB before the copy fails. Please mention this in the fragment.
  3. Every call now allocates and copies, and a NUL-terminated text is copied in full even when the match is at its start. Speed was not measured.

Suggested action: add the throwing test (1) and the fragment note (2); then merge

AI-assisted review (Claude Code) · head 1476b1e39a · base main 23b8772462

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013384689 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25528#pullrequestreview-6013384689). Originally posted by [throny](https://github.com/throny) on 2026-11-22T16:56:53Z. **Review:** COMMENTED --- ### Review: ⚠️ the search wrappers match ICU 78.1, but the tests also pass on `main` **Basis:** code read against `3rdparty/icu` `049e0d6a42` (`ustring.cpp` `u_strFindFirst`/`u_strFindLast`) · head `1476b1e39a` **Checked** - The shortcut order matches ICU: a null needle or count < -1 returns the text, null text returns null, and an empty needle returns the text before the text is read. A -1 operand keeps its NUL in the copy, and a counted operand copies exactly `count` units, so ICU sees the same window, including the surrogate-boundary checks. - `Utf16Search.cpp:65` maps the match back to the guest pointer. -1 operands are read in chunks that end on a page boundary, stopping at the NUL. - The earlier odd-address alignment concern doesn't hold: parity is relative to the operand, and the scan restarts at `offset & ~1`. **Findings** 1. The negative control posted on the PR shows `guest_icu_utf16_search` **Passed** with `Utf16Search.cpp` reverted to `main`, so the new cases don't pin the change. The behaviour that changes is that an unreadable operand throws instead of faulting. Please add a case with an unmapped (`PROT_NONE`) operand that expects a throw, and one with unreadable text and an empty needle that expects the text back. 2. `Utf16Search.cpp:24-33`: a counted operand is now copied in full up front. A guest that passes a `count` larger than its mapping, where the match comes first, used to succeed because ICU stops at the match; it now throws. A count near `INT32_MAX` also grows a host buffer toward 4 GB before the copy fails. Please mention this in the fragment. 3. Every call now allocates and copies, and a NUL-terminated text is copied in full even when the match is at its start. Speed was not measured. **Suggested action:** add the throwing test (1) and the fragment note (2); then merge <sub>AI-assisted review (Claude Code) · head `1476b1e39a` · base `main` `23b8772462`</sub>
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!25528
No description provided.