test(libSceIcu): check the closed mapping with msync so the test builds on macOS #23659

Closed
Romannachwievor wants to merge 1 commit from upstream-pr/23659 into main
Romannachwievor commented 2026-11-19 11:56:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Romannachwievor on 2026-11-19T11:56:36Z.


What

core/libs/prx/libSceIcu/tests/DataMemoryClose.cpp (from #23487) checks that udata_close unmapped the page by calling mincore(mapping, pageSize, &residency) with an unsigned char vector. The macOS SDK declares int mincore(const void*, size_t, char*), so the file fails to compile on macOS ("no matching function for call to 'mincore'") and the full macOS build stops there. CI only builds the relinker on macOS, so this did not show up in the PR checks.

Changing the vector type alone is not enough. On macOS, mincore on a page that was just unmapped returns 0 instead of failing with ENOMEM, so the test then aborts at the Require(mincore(...) == -1) line. A standalone C program on this machine (mmap one page, munmap it, call each function) gave:

mapped page unmapped page
mincore 0 0
msync(MS_ASYNC) 0 -1, ENOMEM

Both checks now use msync(mapping, pageSize, MS_ASYNC), which fails with ENOMEM for an unmapped range on Linux and macOS (both man pages) and returns 0 while the page is still mapped. Windows keeps its VirtualQuery check.

Tested

macOS 26.5 on an M1, x86_64 Release build under Rosetta 2, Apple clang 21.0.0, main 4fa81a86fb plus #17425 and #11049 (needed to build on macOS). The full build completes with this change. guest_icu_recovered_signatures passed 3 of 3 runs. With only the vector type changed to char, it failed at the mincore check in 3 of 3 runs. The probe above gave the same results built for x86_64 and arm64. tools/check_conventions.py --base origin/main passes.

Linux: PrivacyOnion built guest_icu_recovered_signatures_tests and ran guest_icu_recovered_signatures on Ubuntu 24.04, GCC 13.3, Ninja, Release against this head; it passed.

I did not run it on Windows.

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

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5394410213 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23659). Originally posted by [Romannachwievor](https://github.com/Romannachwievor) on 2026-11-19T11:56:36Z. --- ### What `core/libs/prx/libSceIcu/tests/DataMemoryClose.cpp` (from #23487) checks that `udata_close` unmapped the page by calling `mincore(mapping, pageSize, &residency)` with an `unsigned char` vector. The macOS SDK declares `int mincore(const void*, size_t, char*)`, so the file fails to compile on macOS ("no matching function for call to 'mincore'") and the full macOS build stops there. CI only builds the relinker on macOS, so this did not show up in the PR checks. Changing the vector type alone is not enough. On macOS, `mincore` on a page that was just unmapped returns 0 instead of failing with `ENOMEM`, so the test then aborts at the `Require(mincore(...) == -1)` line. A standalone C program on this machine (mmap one page, munmap it, call each function) gave: | | mapped page | unmapped page | |---|---|---| | `mincore` | 0 | 0 | | `msync(MS_ASYNC)` | 0 | -1, `ENOMEM` | Both checks now use `msync(mapping, pageSize, MS_ASYNC)`, which fails with `ENOMEM` for an unmapped range on Linux and macOS (both man pages) and returns 0 while the page is still mapped. Windows keeps its `VirtualQuery` check. ### 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. --> macOS 26.5 on an M1, x86_64 Release build under Rosetta 2, Apple clang 21.0.0, main `4fa81a86fb` plus #17425 and #11049 (needed to build on macOS). The full build completes with this change. `guest_icu_recovered_signatures` passed 3 of 3 runs. With only the vector type changed to `char`, it failed at the `mincore` check in 3 of 3 runs. The probe above gave the same results built for x86_64 and arm64. `tools/check_conventions.py --base origin/main` passes. Linux: PrivacyOnion built `guest_icu_recovered_signatures_tests` and ran `guest_icu_recovered_signatures` on Ubuntu 24.04, GCC 13.3, Ninja, Release against this head; it passed. I did not run it on Windows. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted: yes (Claude Code)
PrivacyOnion commented 2026-11-19 12:03:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T12:03:12Z.

Review: CHANGES_REQUESTED


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

  • Conventions: tools/check_conventions.py failed.
    (pull request): error: [pr-template] Fill in the pull request template: add the '### Tested' heading of the template
    (pull request): error: [pr-template] Fill in the pull request template: add the '### Checklist' heading of the template
    2 findings, 2 errors; GitHub shows at most 10 error annotations, the job summary lists all
    
  • Build: guest_icu_recovered_signatures_tests built cleanly.
  • CTest (guest_icu_recovered_signatures):
    1/1 Test #3928: guest_icu_recovered_signatures ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5974624102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23659#pullrequestreview-5974624102). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T12:03:12Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `98707dd01e`: - **Conventions**: `tools/check_conventions.py` failed. ``` (pull request): error: [pr-template] Fill in the pull request template: add the '### Tested' heading of the template (pull request): error: [pr-template] Fill in the pull request template: add the '### Checklist' heading of the template 2 findings, 2 errors; GitHub shows at most 10 error annotations, the job summary lists all ``` - **Build**: `guest_icu_recovered_signatures_tests` built cleanly. - **CTest** (`guest_icu_recovered_signatures`): ``` 1/1 Test #3928: guest_icu_recovered_signatures ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` Requesting changes for the points above.
MarcZX10 commented 2026-11-19 12:52:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T12:52:47Z.

Review: APPROVED


Reviewed — looks good

The changed assertions now check that msync rejects the unmapped range on POSIX, and the reviewed change has no verified blocking defects.

What I ran

Reviewed head 98707dd01e0da81fec98c32b96181a3901c724d4 using repo_read.py tools. 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. The bundle listed one changed file, and its full text was included. files.json was not available as a review document.

Results

Check Result Note
Diff review passed Both POSIX assertions updated
Build and tests not run Author reports platform runs

Findings

Blocking

None.

Non-blocking

None.

Not verified

Builds and tests were not run by this review. Windows behavior was not verified; the author also reports not testing Windows.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5975361187 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23659#pullrequestreview-5975361187). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T12:52:47Z. **Review:** APPROVED --- # Reviewed — looks good The changed assertions now check that `msync` rejects the unmapped range on POSIX, and the reviewed change has no verified blocking defects. ## What I ran Reviewed head `98707dd01e0da81fec98c32b96181a3901c724d4` using `repo_read.py` tools. 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`. The bundle listed one changed file, and its full text was included. `files.json` was not available as a review document. ## Results | Check | Result | Note | |---|---|---| | Diff review | passed | Both POSIX assertions updated | | Build and tests | not run | Author reports platform runs | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Builds and tests were not run by this review. Windows behavior was not verified; the author also reports not testing Windows. ## To get this to a good state Nothing is required.
Jazeupoi commented 2026-11-20 10:45:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-20T10:45:52Z.

Review: COMMENTED


Ran it on a second Mac: Apple M4, macOS 27.0.1, Apple clang (Command Line Tools), x86_64 Release build under Rosetta 2. Head 98707dd01e applied onto main e825fa1492 with #17425 and #11049 (needed for the macOS build); clean apply.

Tree guest_icu_recovered_signatures_tests
main does not build: DataMemoryClose.cpp:124 and :164, no matching function for call to 'mincore'
this PR builds; guest_icu_recovered_signatures passes 3 of 3 (ICU recovered signature tests passed)

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5991383262 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23659#pullrequestreview-5991383262). Originally posted by [Jazeupoi](https://github.com/Jazeupoi) on 2026-11-20T10:45:52Z. **Review:** COMMENTED --- Ran it on a second Mac: Apple M4, macOS 27.0.1, Apple clang (Command Line Tools), x86_64 Release build under Rosetta 2. Head `98707dd01e` applied onto `main` `e825fa1492` with #17425 and #11049 (needed for the macOS build); clean apply. | Tree | `guest_icu_recovered_signatures_tests` | |---|---| | `main` | does not build: `DataMemoryClose.cpp:124` and `:164`, `no matching function for call to 'mincore'` | | this PR | builds; `guest_icu_recovered_signatures` passes 3 of 3 (`ICU recovered signature tests passed`) | AI-assisted: yes (Claude Code)

Pull request closed

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!23659
No description provided.