fix(tests): check the closed ICU data mapping with msync on macOS #24921

Merged
XIIYAZ merged 1 commit from upstream-pr/24921 into main 2026-11-21 11:57:28 +00:00
XIIYAZ commented 2026-11-21 11:01:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XIIYAZ on 2026-11-21T11:01:17Z.


What

On macOS, DataMemoryClose.cpp, added with udata_close (ee6f7dd1d2), does not compile, so a full build with -DBUILD_TESTING=ON stops:

core/libs/prx/libSceIcu/tests/DataMemoryClose.cpp:124:13: error: no matching function for call to 'mincore'

The test confirms that udata_close unmapped the data by calling mincore on the mapping and expecting ENOMEM, which is what Linux returns for an unmapped page. macOS declares mincore(const void*, size_t, char*), not unsigned char*. With the type fixed, the check still fails on macOS (guest_icu_recovered_signatures aborts at the errno == ENOMEM line), because macOS mincore succeeds on an unmapped page. A standalone program on macOS shows both calls on the same pages:

mincore, unmapped page:  r=0  errno=0
msync,   mapped page:    r=0  errno=0
msync,   unmapped page:  r=-1 errno=12 (ENOMEM)

On macOS the test now checks the unmapped range with msync(mapping, pageSize, MS_ASYNC), which fails with ENOMEM for an unmapped page and succeeds for a mapped one. Linux keeps mincore, and Windows is unchanged.

Tested

  • Apple M4, macOS 26.7.3, Apple clang 21.0.0, full Release build of main with -DBUILD_TESTING=ON, x86_64 under Rosetta
  • Before: the test fails to compile. With only the vector type fixed: guest_icu_recovered_signatures aborts at the ENOMEM check. After this change: it passes.
  • python3 tools/check_conventions.py --base origin/main passes.

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
  • 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: none (no GPU work)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5427122251 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24921). Originally posted by [XIIYAZ](https://github.com/XIIYAZ) on 2026-11-21T11:01:17Z. --- ### What On macOS, `DataMemoryClose.cpp`, added with `udata_close` (ee6f7dd1d2), does not compile, so a full build with `-DBUILD_TESTING=ON` stops: ``` core/libs/prx/libSceIcu/tests/DataMemoryClose.cpp:124:13: error: no matching function for call to 'mincore' ``` The test confirms that `udata_close` unmapped the data by calling `mincore` on the mapping and expecting `ENOMEM`, which is what Linux returns for an unmapped page. macOS declares `mincore(const void*, size_t, char*)`, not `unsigned char*`. With the type fixed, the check still fails on macOS (`guest_icu_recovered_signatures` aborts at the `errno == ENOMEM` line), because macOS `mincore` succeeds on an unmapped page. A standalone program on macOS shows both calls on the same pages: ``` mincore, unmapped page: r=0 errno=0 msync, mapped page: r=0 errno=0 msync, unmapped page: r=-1 errno=12 (ENOMEM) ``` On macOS the test now checks the unmapped range with `msync(mapping, pageSize, MS_ASYNC)`, which fails with `ENOMEM` for an unmapped page and succeeds for a mapped one. Linux keeps `mincore`, and Windows is unchanged. ### Tested - Apple M4, macOS 26.7.3, Apple clang 21.0.0, full Release build of `main` with `-DBUILD_TESTING=ON`, x86_64 under Rosetta - Before: the test fails to compile. With only the vector type fixed: `guest_icu_recovered_signatures` aborts at the `ENOMEM` check. After this change: it passes. - `python3 tools/check_conventions.py --base origin/main` passes. ### 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) - [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: none (no GPU work) - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-21 11:10:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T11:10:40Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_recovered_signatures_tests built cleanly.
  • CTest (guest_icu_recovered_signatures):
    1/1 Test #4091: guest_icu_recovered_signatures ...   Passed    0.04 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • DataMemoryClose.cpp Mapping(): verified msync(mapping, pageSize, MS_ASYNC) on macOS correctly fails with -1 and sets errno to ENOMEM on unmapped pages.
    • DataMemoryClose.cpp Heap(): verified unmapped memory check is properly guarded by #if defined(APPLE) and preserves mincore on Linux.
    • POSIX / Darwin API semantics: verified msync and MS_ASYNC signatures and ENOMEM return specifications for unmapped address ranges.
    • AGENTS.md compliance: verified no forbidden comments are added and preprocessor directives comply with repo standards.
    • Cross-platform portability: verified Linux and Windows test paths remain intact with zero regressions.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004816814 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24921#pullrequestreview-6004816814). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T11:10:40Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0153abe2fe`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_recovered_signatures_tests` built cleanly. - **CTest** (`guest_icu_recovered_signatures`): ``` 1/1 Test #4091: guest_icu_recovered_signatures ... Passed 0.04 sec 100% tests passed, 0 tests failed out of 1 ``` - **Code reading**: - DataMemoryClose.cpp Mapping(): verified msync(mapping, pageSize, MS_ASYNC) on macOS correctly fails with -1 and sets errno to ENOMEM on unmapped pages. - DataMemoryClose.cpp Heap(): verified unmapped memory check is properly guarded by #if defined(__APPLE__) and preserves mincore on Linux. - POSIX / Darwin API semantics: verified msync and MS_ASYNC signatures and ENOMEM return specifications for unmapped address ranges. - AGENTS.md compliance: verified no forbidden comments are added and preprocessor directives comply with repo standards. - Cross-platform portability: verified Linux and Windows test paths remain intact with zero regressions. Looks Good To Me
MarcZX10 commented 2026-11-21 11:17:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:17:15Z.

Review: APPROVED


Reviewed — looks good

The change uses msync for the macOS unmapped-range assertion while preserving mincore on other Unix platforms; the changed test file was read in full at the specified head.

What I ran

  • Head: 0153abe2fe6b41fa5351aabd977092012c1f2f27.
  • No build or test commands were run. Read description.md, commits.md, manifest.json, diff.patch, and the full changed file core/libs/prx/libSceIcu/tests/DataMemoryClose.cpp. No changed files were excluded by the manifest.

Results

Check Result Note
Source review passed One changed test file read
Build and tests not run Author reports macOS build and test results

Findings

Blocking

None.

Non-blocking

None.

Not verified

The reported macOS build, runtime test and conventions check were not run during this review. No other files were changed or excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004848536 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24921#pullrequestreview-6004848536). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T11:17:15Z. **Review:** APPROVED --- # Reviewed — looks good The change uses `msync` for the macOS unmapped-range assertion while preserving `mincore` on other Unix platforms; the changed test file was read in full at the specified head. ## What I ran - Head: `0153abe2fe6b41fa5351aabd977092012c1f2f27`. - No build or test commands were run. Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and the full changed file `core/libs/prx/libSceIcu/tests/DataMemoryClose.cpp`. No changed files were excluded by the manifest. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | One changed test file read | | Build and tests | not run | Author reports macOS build and test results | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The reported macOS build, runtime test and conventions check were not run during this review. No other files were changed or excluded. ## 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!24921
No description provided.