Skip to content

fix(libc): ignore empty macOS write-watch ranges - #5753

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Tiberon-Kuiper:fix/macos-empty-write-watch-ranges
Oct 15, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Tiberon-Kuiper:fix/macos-empty-write-watch-ranges

Conversation

@Tiberon-Kuiper

@Tiberon-Kuiper Tiberon-Kuiper commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What

On macOS, an empty write-watch range at an unaligned address was rounded out to its containing page before checking its length. Registering or unregistering zero bytes could change coverage; an empty protection notification could change the recorded page protection; and an empty host-write end could remove a real active write on that page, allowing collection to protect it prematurely.

Check the original range before page rounding in registration, unregistration, protection changes and host-write begin/end. Keep the existing check after rounding. No Linux or Windows backend code changes.

Tested

macOS 26.6.2, Apple Silicon, AppleClang 21.0.0.21000334, Release:

  • The new write_watch_empty regression fails on the original production source with an empty registration watches a page and passes with the fix.

  • Standalone macOS write-watch suite: 9/9 pass natively (arm64), and 9/9 pass as x86_64 under Rosetta. Both builds compile the production GuestWriteWatch.cpp.

  • The new test covers aligned and unaligned empty ranges, existing coverage, actual kernel page protections, an active nonempty host write, and tracking of a subsequent real write. Each CTest retains the existing 30-second limit; all observed tests finished in under one second.

  • python3 tools/check_conventions.py --base origin/main, python3 tools/check_test_registration.py /private/tmp/anyps5-write-watch and git diff --check pass.

  • python3 tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/macos-empty-write-watch-ranges reports no overlap with open pull requests.

Not tested: full-project builds, Linux/Windows runtime tests or titles. Full build validation is pending; this PR is a draft. A maintainer can start the project's manual Build workflow for this PR. No title unblock or performance improvement is claimed.

While the code was written by hand, AI assisted with the PR due to language barriers and guided the GitHub workflow.

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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Codex)

@Tiberon-Kuiper
Tiberon-Kuiper marked this pull request as ready for review October 14, 2026 09:33
@011010

011010 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Verified on macOS 27.0.1 (26A434), Apple M4, x86-64 under Rosetta 2: the standalone write-watch build (core/libs/tests/write_watch) passes ctest 9/9 with this change.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/WriteWatch.cpp
core/libs/tests/write_watch/CMakeLists.txt

@adriadam10 adriadam10 self-assigned this Oct 15, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the diff: the length check now runs on the original range before page rounding in Register, Unregister, ProtectionChanged, BeginHostWrite and EndHostWrite of the macOS backend, and the post-rounding check is kept. No Linux/Windows code changes. write_watch_empty covers aligned and unaligned empty ranges, kernel protections and an active host write; 9/9 confirmed by @011010 on macOS (Rosetta). Linux build and ctest are green (the test is macOS-only); merging once the macOS job in the full Build passes.

@adriadam10
adriadam10 merged commit 0c4816f into boykopovar:main Oct 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants