Skip to content

fix(libc): resolve the read traps that refuse an untrapped access on macOS - #233

Merged
utkuhalis merged 1 commit into
AnyTogether:mainfrom
hedibravofox:fix/macos-import-trap-resolve
Dec 4, 2026
Merged

utkuhalis merged 1 commit into
AnyTogether:mainfrom
hedibravofox:fix/macos-import-trap-resolve

Conversation

@hedibravofox

@hedibravofox hedibravofox commented Dec 4, 2026 •

Copy link
Copy Markdown

What

Follow-up to #226. On macOS, #226 refuses an untrapped access over read-trapped pages, but leaves the traps in place. A host import over a large heap is then refused for as long as any page in it stays trapped, and the driver falls back to copying through the CPU. In Grand Theft Auto V that stops the game:

compute shader 0x369a8f400: AGC graphics: a CPU read of 0x3ef5d0000+0x7db30000 overlaps multisampled color target 0x400400000+0x80000 (2 samples), whose samples are only on the host: guest access to it is not implemented

The first access to a trapped range is still refused, so a copy can still happen before the traps are resolved.

Tested

macOS 27.2.1, Apple M5 Pro, x86-64 build under Rosetta 2 (AppleClang 21.0.0, Release):

#226 as merged This PR
Logged refusals of the 4.6 GB heap import 143 10
Heap imported never yes
Result stopped on the error above after about 1 minute played for about 5 minutes without a driver error, until I quit
  • Not run: the GPU tests, since this changes only libc.

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: PPSA04263 (Grand Theft Auto V) past this error on macOS
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

…macOS

A refused untrapped access left the traps over its range in place, so a
host import over a large heap was refused for as long as any page in it
stayed trapped. The refusal now queues those traps on the resolver thread
without waiting, and a later access is granted once they are resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@utkuhalis

Copy link
Copy Markdown
Collaborator

Thanks, this closes the gap #226 left. Checked against the resolver:

  • The refusal still releases _lock before it queues anything and never waits on a slot, so the import path (under the write tracker lock and the imports mutex) can't re-enter the driver. The deadlock fix(libc): refuse untrapped access over read traps on macOS #226 fixed stays fixed.
  • Queuing one page per overlapping trap is enough: resolve(page) takes every trap that overlaps the page through takeTraps and resolves each one whole.
  • A page queued again before its first resolution finishes finds no trap, so resolver isn't called twice. The test's TakeTrapCalls().size() == 1 checks exactly that.
  • Detached slots only take _slots[0..15], and resolveTrap scans all 32, so a faulting thread always has a free slot. detached is written before the Queued release store and read after the acquire CAS, so the resolver sees it.

Thanks for noting the overlap with boykopovar#26221. We'll reconcile it when that comes in with an upstream merge. I'll merge once CI is green; the macOS job is waiting for a runner and I'll rerun it if it gets cancelled.

@utkuhalis
utkuhalis merged commit 9feec4e into AnyTogether:main Dec 4, 2026
122 of 150 checks passed
@utkuhalis

Copy link
Copy Markdown
Collaborator

Merged, thanks! dag294-alt, this is on main now if you want to do the Wolverine rerun you mentioned on #226.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants