fix(libc): forward non-write faults from watched macOS pages #12117
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12117"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by plexerPK on 2026-10-27T21:43:19Z.
What
The macOS write-watch handler treated any fault in a watched writable page as a write. Calling a non-executable watched page, or reading a watched file mapping after its backing was truncated, repeatedly returned to the same fault instead of delivering it to the previous handler/default action. This occurs both before and after collection and during a host-write scope.
Classify the saved CPU exception before recording a write: an x86-64 page fault with the write bit set, or an arm64 data abort with WnR set. Non-write faults follow the existing forwarding path. The writable-state retry remains available for concurrent writes whose first fault has already restored the page.
The constants follow Apple's XNU x86 trap definitions and arm64 ESR definitions. No third-party source is copied.
Add native subprocess regressions for execute and backing-read faults across fresh/collected pages and active/inactive host writes (eight cases). A child alarm bounds the old infinite retry; a successful case must terminate with SIGBUS/SIGSEGV. Document the separate existing limitation for write faults after backing truncation; this change does not resolve them.
Ownership preflight covered all 1,383 open PRs and 243 open issues. #11801 adds default re-raising for user-generated signals; #7192 exposes an address-based hook for fault delivery. Neither implements CPU access classification. No author coordination message has been sent.
Tested
macOS 27.0.1 (26A434), arm64, Apple clang 21.0.0, standalone actual production
core/libs/tests/write_watchcomponent, Release:f5fefb982c53672bda23767304f97aac2eec5207: existing 10/10 tests pass. The two new regression tests fail at their child alarm (2.25 s / 2.01 s). A bounded diagnostic probe independently observes eight repeated faults for both NX-page states and both backing-read states, while normal writes succeed.--repeat until-fail:3. The four-thread concurrent-write test passes 20 additional repetitions.-DCMAKE_OSX_ARCHITECTURES=x86_64. Compile only: no Intel/Rosetta execution is available on this host.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpass. Officialtools/pr_overlap.py --branch codex/macos-write-watch-nonwrite-faults --repo boykopovar/AnyPS5reports no confirmed line/export conflicts. It reports 19 comparisons unavailable because those PRs conflict with main: 18 touch unrelated libc debt entries; #7192 adds the hook described above. Their authored diffs were inspected manually; none changes this classification or the new backing-lifetime debt entry.No full libc/libkernel build, title/guest execution, Linux/Windows runtime or GPU claim. The production change is confined to the macOS backend. Hosted CI remains separate from these local results.
Additional verification of the same head
write-watch (macos-15-intel)andwrite-watch (macos-15)jobs now report SUCCESS for heade295dbaa362a5fdd90c7315b875f066fd1b78a5b; the relinker matrix is also green. This is separate from the local arm64 evidence above.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T15:53:12Z.
Review: APPROVED
Reviewed exact head
e295dbaa362a5fdd90c7315b875f066fd1b78a5. The fault classifier accepts only the synchronous SIGSEGV/SIGBUS codes belowSI_USER, then recognizes x86-64 page-fault writes from trap 14/error bit 1 and arm64 data-abort writes from EC 0x24/WnR. Non-write faults and unavailable context continue through the pre-existing forwarding path. The focused tests cover execute and missing-backing read faults across fresh/collected pages and active/inactive host-write scopes; the author and independent reviewers report native arm64 and x86-64-under-Rosetta runs, repeated red controls, and clean ASan/UBSan runs with the documented signal-handler options. The hosted macOS write-watch matrix and repository checks are green. I independently verified the exact diff is 72 lines across the implementation, focused tests, CMake registrations and debt entry; current-main merge-tree andgit diff --checkare clean. I did not run the macOS-specific tests locally, and this review makes no console behavior claim. I found no blocking issue.