Repository navigation
Conversation
The async read-trap worker claimed a trap before its resolver callback acquired GuestMemory::GpuMutex(). An importer holding that mutex then waited for the claimed trap while the worker's callback waited for the same mutex, deadlocking the import (boykopovar#15742). Add a GuestWriteWatchSetReadTrapLock hook. The worker now waits for other resolvers, acquires the GPU mutex, claims the trap, releases the mutex, and only then runs the callback. Acquiring before claiming lets a mutex-holding importer resolve the trap itself via the existing bypass; releasing before the callback keeps the flush hook at depth 1 so the GPU wait stays unlocked. Waiting before acquiring keeps the worker from holding the mutex while blocked on another resolver. Wire the hook to GpuMutex in the AGC driver and add a locked-copy case to the ImportReadTrap fixture that reproduces the deadlock without the fix.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The inspected changes show no verified blocking defect, but two changed files were available only for targeted hunk review, so a formal approval is not justified.
What I ran
Reviewed the prepared diff and targeted source ranges at head 6f1729df1ae816dc6aece4ab5ba8d73dc52d8d48 using repo_read.py tools. No test commands were run; the test results in the PR description are author-reported.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | Resolver flow and test fixture inspected |
| Tests | not run | PR description reports macOS fixture runs |
| Full changed-file review | not run | Two files were too large for the review folder |
Negative control
Not run by this review. The PR description reports a variant without the lock hook deadlocked.
Findings
Blocking
None verified in the inspected changes.
Non-blocking
None.
Sources
Not verified
Full text was read for core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_import_read_trap_tests.cmake, core/libs/prx/libSceAgcDriver/tests/execution/ImportReadTrap.cpp, core/libs/prx/libc/include/GuestWriteWatch.hpp, and core/libs/prx/libc/src/GuestWriteWatch.cpp. Targeted changed hunks and surrounding context were read for core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp and core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp; their full text was excluded because the files were too large. Tests were not run here. Full application build, complete CTest suite, Windows runtime, and PS5 hardware behavior were not verified.
To get this to a good state
Nothing is required.
|
Other open pull requests say they fix the same issue, so they may implement the same thing: 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.
|
|
Windows NVIDIA check of head Setup: Windows 11 Home 10.0.26300, i9-13900K, WinLibs GCC 15.2.0, Release, RTX 4080 (
The three extra skips are this PR's Not checked: macOS, the path this changes. AI-assisted: yes |
|
Thanks for the run on the RTX 4080 (driver 32.0.16.2101). Main and the merge both pass 1843 with 0 VUID lines, and the three extra skips are the new read-trap tests that need macOS, as intended. I'll put the macOS result in the PR body once I have it. AI-assisted: yes |
|
Thanks for the review. I'm glad to answer questions on the two files you could only check by hunk. AI-assisted: yes |
|
Mac result for the current head
AI-assisted: yes |
|
Linux NVIDIA run with the Khronos validation layer, for the Linux host-import paths the change should leave alone (the NVIDIA run so far is on Windows). Setup: Arch Linux, kernel 7.3.4, GCC 16.2.1 Release, NVIDIA GeForce RTX 4090 (10de:2684), driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head
No new AI-assisted: yes (Claude Code) |
What
ImportWatchedon macOS deadlocks when a guest write-watch read trap is resolved on the importing thread (#15742). The async read-trap worker claimed a trap (registered it in_resolving) before its resolver callback acquiredGuestMemory::GpuMutex(). An importer holding that mutex then waited inwaitForResolvingfor the claimed trap, while the worker's callback blocked acquiring the same mutex — a lock-order cycle.Add a
GuestWriteWatchSetReadTrapLock_nid_postfix(acquire, release)hook (mirroringSetReadTrapBypass) and reorder the worker: wait for other resolvers, acquire the GPU mutex, claim the trap, release the mutex, run the callback, then untrap.GpuMutexnever sees a foreign claim, so it resolves the trap itself through the existing bypass; the worker later finds it gone and no-ops.GpuMutexwhile blocked on another resolver.The AGC driver wires the hook to
GpuMutexinLabelTrapsEnabled. The two-argumentGuestWriteWatchResolveReadTrapsLater_nid_postfixABI is unchanged.Fixes #15742
Tested
Apple M5 Pro, macOS 27.3, x86_64 Release under Rosetta, MoltenVK (Vulkan SDK 1.4.363.1),
VK_LAYER_KHRONOS_validationinserted,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1. This is a synthetic Vulkan component fixture, not console or title evidence.agc_driver_import_read_trap(direct),_copyand_locked_copy: 3/3 runs each passed (CTest, 100% of 3), validation layer inserted, 0 VUIDs. The locked-copy case resolves in ~0.2 s with no deadlock.waitForResolvingand the worker blocked onGpuMutex— the cycle this change removes.python tools/check_conventions.py --base origin/mainandpython tools/debt_fold.py --check: passed.git diff --check origin/main...HEAD: clean.queued_indirect_read_ordertimeout and label/pixel execution-test failures on this branch are unrelated to this change (they persist with the lock hook and the import hook removed) and are not claimed fixed. No broad-suite or console-equivalence claim is made.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)