feat(libSceIcu): implement data memory close #23487

Merged
Thimo188 merged 1 commit from upstream-pr/23487 into main 2026-11-19 05:53:18 +00:00
Thimo188 commented 2026-11-19 04:41:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Thimo188 on 2026-11-19T04:41:15Z.


What

Implement udata_close_nid_postfix with its exact public ICU 68 void(UDataMemory*) ABI and lifecycle behavior. The ICU 68.2 and bundled ICU 78 handle layouts are byte-compatible, but bundled ICU is compiled without file I/O, so this preserves ICU 68's platform map teardown directly before using ICU allocation ownership for heap handles or exact reinitialization for stack handles. Add focused coverage for null, zeroed and populated stack handles, repeated defined stack close, direct ICU parity, real mapped stack and heap handles, guards, errno, and the complete 56-byte layout.

Tested

Ubuntu 24.04 linux/amd64 Docker (anyps5-dev:24.04): fresh focused build 448/448; strengthened mapped-heap lifecycle test; post-rename incremental build 9/9; post-rebase build 81/81; guest_icu_recovered_signatures passed on every final build; public-header audit and all compile batches 65/65; final test_registration, check_test_registration_script, public_headers, public_headers_compile_63, and focused CTest 5/5; exact exported C symbol verified. ICU 68.2 commit 84e1f26ea77152936e70d53178a816dbfbf69989 and bundled ICU 78 UDataMemory, udata_close, initialization, allocator ownership, and POSIX/Win32/stdio map teardown paths were compared directly. Diff, debt-fold, conventions, current-base rebase, and overlap gates were run; no open PR implements this function.

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:5388941802 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23487). Originally posted by [Thimo188](https://github.com/Thimo188) on 2026-11-19T04:41:15Z. --- ### What Implement `udata_close_nid_postfix` with its exact public ICU 68 `void(UDataMemory*)` ABI and lifecycle behavior. The ICU 68.2 and bundled ICU 78 handle layouts are byte-compatible, but bundled ICU is compiled without file I/O, so this preserves ICU 68's platform map teardown directly before using ICU allocation ownership for heap handles or exact reinitialization for stack handles. Add focused coverage for null, zeroed and populated stack handles, repeated defined stack close, direct ICU parity, real mapped stack and heap handles, guards, errno, and the complete 56-byte layout. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 24.04 linux/amd64 Docker (`anyps5-dev:24.04`): fresh focused build 448/448; strengthened mapped-heap lifecycle test; post-rename incremental build 9/9; post-rebase build 81/81; `guest_icu_recovered_signatures` passed on every final build; public-header audit and all compile batches 65/65; final `test_registration`, `check_test_registration_script`, `public_headers`, `public_headers_compile_63`, and focused CTest 5/5; exact exported C symbol verified. ICU 68.2 commit `84e1f26ea77152936e70d53178a816dbfbf69989` and bundled ICU 78 `UDataMemory`, `udata_close`, initialization, allocator ownership, and POSIX/Win32/stdio map teardown paths were compared directly. Diff, debt-fold, conventions, current-base rebase, and overlap gates were run; no open PR implements this function. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
PrivacyOnion commented 2026-11-19 04:43:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T04:43:38Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_recovered_signatures_tests built cleanly.
  • CTest (guest_icu_recovered_signatures):
    1/1 Test #3903: guest_icu_recovered_signatures ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/RecoveredSignatures.hpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/DataMemoryClose.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceIcu/DataMemoryClose.cpp: verified udata_close_nid_postfix correctly handles nullptr without side effects or errno mutation
    • core/libs/prx/libSceIcu/DataMemoryClose.cpp: verified mmap/munmap length arithmetic (map - mapAddr) and Windows UnmapViewOfFile/CloseHandle lifecycle match ICU udatamem.cpp upstream semantics
    • core/libs/prx/libSceIcu/DataMemoryClose.cpp: verified heapAllocated branch calls uprv_free(data) and stack branch resets fields with std::memset(data, 0, sizeof(*data)) and length = -1
    • core/libs/prx/libSceIcu/RecoveredSignatures.hpp: verified signature void APS5_VABI udata_close_nid_postfix(UDataMemory* data) matches ICU ABI and header declarations
    • core/libs/prx/libSceIcu/tests/DataMemoryClose.cpp: verified struct layout assertions (sizeof 56, offsets of all members), null check, stack initialization, parity with udata_close, and platform memory unmapping (Windows VirtualQuery MEM_FREE, Linux mincore ENOMEM)

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969439158 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23487#pullrequestreview-5969439158). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T04:43:38Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `ee6f7dd1d2`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_recovered_signatures_tests` built cleanly. - **CTest** (`guest_icu_recovered_signatures`): ``` 1/1 Test #3903: guest_icu_recovered_signatures ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/RecoveredSignatures.hpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/DataMemoryClose.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceIcu/DataMemoryClose.cpp: verified udata_close_nid_postfix correctly handles nullptr without side effects or errno mutation - core/libs/prx/libSceIcu/DataMemoryClose.cpp: verified mmap/munmap length arithmetic (map - mapAddr) and Windows UnmapViewOfFile/CloseHandle lifecycle match ICU udatamem.cpp upstream semantics - core/libs/prx/libSceIcu/DataMemoryClose.cpp: verified heapAllocated branch calls uprv_free(data) and stack branch resets fields with std::memset(data, 0, sizeof(*data)) and length = -1 - core/libs/prx/libSceIcu/RecoveredSignatures.hpp: verified signature void APS5_VABI udata_close_nid_postfix(UDataMemory* data) matches ICU ABI and header declarations - core/libs/prx/libSceIcu/tests/DataMemoryClose.cpp: verified struct layout assertions (sizeof 56, offsets of all members), null check, stack initialization, parity with udata_close, and platform memory unmapping (Windows VirtualQuery MEM_FREE, Linux mincore ENOMEM) Looks Good To Me
MarcZX10 commented 2026-11-19 04:55:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T04:55:37Z.

Review: APPROVED


Reviewed — looks good

The implementation and changed files reviewed support merging; reported builds and checks were not run during this review.

What I ran

Reviewed head ee6f7dd1d2449dccb96ba0759c25d90066361fd9 using the prepared diff and the pinned repository reader. No build or test commands were run.

Results

Check Result Note
Diff and changed files passed All seven changed files read
Build and tests not run Results in the PR description are author-reported
Repository reader not applicable Used for source inspection

Findings

Blocking

None.

Non-blocking

None.

Not verified

Builds, tests, and platform behavior were not independently verified. The author reports Ubuntu 24.04 builds and checks in the PR description. No files were excluded from the review bundle.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969527011 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23487#pullrequestreview-5969527011). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T04:55:37Z. **Review:** APPROVED --- # Reviewed — looks good The implementation and changed files reviewed support merging; reported builds and checks were not run during this review. ## What I ran Reviewed head `ee6f7dd1d2449dccb96ba0759c25d90066361fd9` using the prepared diff and the pinned repository reader. No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All seven changed files read | | Build and tests | not run | Results in the PR description are author-reported | | Repository reader | not applicable | Used for source inspection | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Builds, tests, and platform behavior were not independently verified. The author reports Ubuntu 24.04 builds and checks in the PR description. No files were excluded from the review bundle. ## To get this to a good state Nothing is required.
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!23487
No description provided.