Repository navigation
fix(agc): land GPU writes over guest memory before a host write into it - #6926
adriadam10 merged 19 commits into
Conversation
A host write into guest memory (a file, AIO or APR read, a socket receive) went straight to the pages. Storage image results pending over the range were stored later, when something read the memory, and a store already recorded or in flight landed whenever its batch ran. Either could overwrite the host's bytes: a write-back recorded before an APR read landed over the file data after it, and a host write into part of a 64 KiB block left the rest of the block without the image's results. libc now calls a host write observer at the start of every GuestArena::HostWrite scope, on every platform. The driver registers one that does what its own guest stores do: it stores the results pending over the range and waits for every recorded or in-flight GPU write there, so the host's bytes land last, as on the console. The driver's own import window on macOS skips it. The test reads a file into guest memory under a HostWrite scope over a storage image's results, with the image's store recorded before the read and with the results still pending, over a whole 64 KiB block and over 4 KiB inside one.
GuestArenaSetHostWriteObserver_nid_postfix becomes GuestArenaSetHostWriteHook_nid_no_patch, taking the address as std::uintptr_t, and the driver's GuestMemory::FlushBeforeHostWrite becomes PrepareHostWrite, so they read as one pair with the host read hook boykopovar#6234 adds (GuestArenaSetHostReadHook_nid_no_patch and PrepareHostRead). The setter is a helper that must not become a NID, so it takes the _nid_no_patch suffix. Behaviour is unchanged.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
CnRJay
left a comment
There was a problem hiding this comment.
The right place to fix this (the host write itself, rather than a store at every flip), and the fast path is cheap (82-98 ns against 7 ns for a 64 KiB write with nothing to wait for). Three questions on the slow path and on teardown.
- When a host write does overlap pending results,
PrepareHostWritewaits for the in-flight batches and the store. The call comes from whatever thread did theread()/recv()/APR read: file I/O threads, the network thread, and the title's own loader threads. A loader that streams into a buffer the GPU is still writing now stalls on a GPU round trip per read, which is the stall the description describes as the cost of the flip-time store, only moved. The PR measures the empty case only. Please add counters (hook calls, calls that waited, time waited) to the[rescache]-style profile line and post them for Epic Mickey's first-level load, so the cost of the slow path is seen on a real title, not only in the test. GuestArenaSetHostWriteHook_nid_no_patch(&PrepareHostWrite)is registered inDriver::Driverand cleared in~Driver. A thread inside aHostWritescope when the driver is destroyed can call the hook after the clear started, or whileDrivermembers it uses are gone. State that the hook is an atomic pointer and what makesPrepareHostWritesafe once the driver is stopping (it should do nothing afterstop()).- The lock audit is in the description, but nothing enforces it. A future
HostWritecall under a mutex the GPU wait needs (the GPU mutex, a libSceNet lock) deadlocks. Add a check in the hook that throws when the thread holds the GPU mutex outside the supported case, the wayDrawPipeline::Draindoes, so a violation is an error and not a hang.
Also: the description says the title has not run the fix yet ("Related", not "Fixes"). A log line from Epic Mickey (PPSA15657) on this branch reaching the first level is what the maintainers will ask for; it is worth getting from the reporter before this is looked at in detail.
Only the driver's destructor cleared the host write hook, so a host write made after Driver::Shutdown still ran PrepareHostWrite and the flush hook behind it: the queued-label branch takes the GPU mutex and records labels against the reset device, and on Linux exit() runs the destructor while title threads still run. stop() now clears the hook before the workers are joined, sets a stopped flag PrepareHostWrite checks after counting itself in flight, and waits for the calls already inside to leave. The wait is bounded to 1 s, as a thread ExitProcess killed inside the hook never leaves. The test records a storage image's store over a range, shuts the driver down, then makes a host write over the range and checks that it no longer reaches the flush hook.
A host write waits for the GPU work over its range before its bytes land. Every HostWrite site is a guest I/O path that holds no driver lock, but one made with GuestMemory::GpuMutex held would take the flush hook's nested locked wait, which hangs if that work needs another thread's hold of the mutex to complete. PrepareHostWrite now counts such a call (GuestMemory::LockedHostWrites) and logs the first one with its thread tag, address and size, then continues. Under APS5_ASSERT_GPU_LOCK=1 it aborts with a [lock] ASSERT: line instead. The debt notes the rule. The test makes a host write while holding the GPU mutex, checks that it returns and that the count moved by one, and that a host write without the mutex is not counted.
Under APS5_PROFILE_DRAW, PrepareHostWrite reads the calling thread's GPU waits (Recorder::ThreadWaitedMs, given to GuestMemory by the driver as it gives ShaderMemory) before and after its flush, and counts the calls, the calls that waited, and the total and longest wait. A [hostwrite] line reports them every 10 s with the other profile lines. The test makes a host write over a range with a recorded store, which counts one call that waited, and one over an idle range, which counts a call that did not.
|
@CnRJay Thanks. All three are in, each with its test in the same commit:
|
|
AMD / Windows run of this PR at 276f67d: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release. Every ctest entry built from the test targets this PR changes passes (2):
AI-assisted: yes (runs made on the device above). |
|
Thanks @keravyn-ops for the AMD runs here, on #6911 and on #6944; they're in each PR's Tested and GPUs-tested lines now. |
|
NVIDIA data point for this PR: head
Not checked: whether the new tests fail on AI-assisted: yes (Claude Code). |
|
Thanks @TheSovietWaffle for the RTX 3080 runs; they're in the Tested and GPUs-tested lines now. |
main 4827f36 adds the shader disk cache include to the driver lifecycle (boykopovar#6641) where this branch adds the guest arena's. Keep both.
jotitadev
left a comment
There was a problem hiding this comment.
A Linux run on NVIDIA and lavapipe, with the hook taken out to see what the new tests catch.
Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. PR merged onto main 12a71f3f5 (clean). ANYPS5_NO_SHADER_CACHE=1, -j1 --timeout 30.
| Run | RTX 3070 | lavapipe |
|---|---|---|
agc_driver_host_write_hook, agc_driver_host_write_pending_storage |
pass 3/3 | pass |
^agc (638 tests), PR vs main |
no new failures (636/638; agc_driver_f16_fma_denormal_modes and agc_driver_fma_mix_f16_denormal_modes fail on main on this GPU too) |
638/638 on both |
The tests don't build on main (they use HostWritesCounted), so as the negative control I removed only the GuestArenaSetHostWriteHook_nid_no_patch(&GuestMemory::PrepareHostWrite) line from Driver::Driver. Both tests fail on both devices, 3/3 on the 3070:
host write over pending storage, a store recorded before a 64 KiB host write: FAILED, byte 0x0 of the file read was overwritten by the image's store after it (0x0, the file has 0x40)
host write over pending storage, a store recorded before a 4 KiB host write: FAILED, byte 0x3000 of the file read was overwritten by the image's store after it (0x0, the file has 0x40)
host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them
host write over pending storage, a 4 KiB host write over pending results: FAILED, byte 0x5 outside the file read holds 0x0, not the image's 0x47, so its results there never landed
So on Linux the file-read path reaches the driver only through this hook, and three of the four cases catch it missing. The third case, a 64 KiB host write over pending results, passes without the hook on both devices, so it does not cover the fix on this platform.
Run on 276f67d36; the current head be2be36b5 only merges main, the PR's five commits are unchanged.
Not run: Windows, AMD, Epic Mickey or any title.
GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
|
Thanks for the Linux runs and the negative control. Your three failures are the same ones the red in Tested shows, and the whole-block case passes on |
Keeps the host-write hook setter next to boykopovar#6184's access observer setter in GuestArena.
# Conflicts: # docs/dev/debt/libSceAgcDriver.md
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 746 tests)Skipped (52)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
BunnyFl
left a comment
There was a problem hiding this comment.
Here's the Windows/AMD run this PR didn't have yet. Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, with this head merged onto current main: agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass, nothing skipped. The hook's path ran on the GPU, not just the fast path: the log shows [hostwrite] 2 host writes, 1 waited for GPU work over their range: 0.08 ms in total, 0.08 ms at most and host write waits: the write over the recorded store waited, the one over the idle range did not. With main's GuestMemory, Lifecycle.cpp and GuestArena sources the tests don't build (HostWritesCounted is new), so a runtime negative control isn't possible here. jotitadev's run without the hook covers that.
CnRJay's slow-path and teardown questions are answered in 276f67d (the [hostwrite] accounting) and 2ff4ed6 (clearing the hook and waiting for calls in flight at stop), and the paired Alone in the Dark runs on current main (3 of 6 without, 6 of 6 with) back the Unblocks line.
XairRrR
left a comment
There was a problem hiding this comment.
Reviewed — approved
The host-write hook (libc → GuestMemory::PrepareHostWrite → FlushGpuWrites) builds and both new tests pass on lavapipe with no new VUIDs. Removing the hook's registration or the teardown in stop() makes the tests fail exactly as the description says. I found nothing blocking.
What I ran
- PR head
59a6f5e41e82a2a7049715f0844da5ffb24a45f4 main4f41f4c375f5abb487dbd184fbc150f31994d762- Merged tree
d1a8dc054612ad49da165b21bf50e32b6d0a6f79 - Machine: Debian 13 VM (32 vCPU, Xeon Gold 6136), GCC 14.2.0, Release, Ninja, lavapipe (Mesa 26.1.6, LLVM 19)
git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...59a6f5e41e82a2a7049715f0844da5ffb24a45f4
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer ctest --test-dir build -V -R '^agc_driver_host_write_(hook|pending_storage)$'
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R '^agc_driver_native_depth_uniform_planes$' # merged tree, then main's production files
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R '^agc_driver_(host_write_(hook|pending_storage)|storage_file_write|graphics|linear_target_direct_write_completion|preparation_scope_settle)$'
# negative controls (see below), each followed by
ninja -C build -j32 -l32 agc_driver_host_write_hook_tests agc_driver_host_write_pending_storage_tests
ctest --test-dir build --output-on-failure -R '^agc_driver_host_write_(hook|pending_storage)$'
Results
| Check | Result |
|---|---|
git diff --check |
clean |
check_conventions.py |
passed |
Configure, build, libs (script) |
ok |
| Selected tests (script, 3702 run) | no new failures, no timeouts; the 9 known failures also fail on main |
check_skips.py |
guest_net_ctl skipped, which also happens on main (not this PR) |
agc_driver_host_write_hook with the validation layer |
passed in 0.46 s, layer inserted, no VUID- |
agc_driver_host_write_pending_storage with the validation layer |
passed in 0.47 s, all 4 cases, write watch "userfaultfd, user mode only", no VUID- |
| Script's validation comparison | one test flagged: agc_driver_native_depth_uniform_planes, VUID-vkCmdDispatch-groupCountX-00386, "test not run on main". The test was added to main after the baseline d1ae628bc2. With main's production files restored it reports the same VUID 4 times, as on the merged tree, so it comes from main. |
Related tests: storage_file_write, graphics, preparation_scope_settle, linear_target_direct_write_completion |
5 passed, 1 skipped (linear_target_direct_write_completion, as in the description's runs) |
New tests, merged tree
[hostwrite] 2 host writes, 1 waited for GPU work over their range: 5.85 ms in total, 5.85 ms at most
[lock] a host write of 0x10000 bytes at 0x7faba6c80000 was made under GuestMemory::GpuMutex on thread tagged 0xffffffff; it waits for GPU work with the mutex held (counted, logged once)
host write waits: the write over the recorded store waited, the one over the idle range did not
host write under the GPU mutex: it returned and was counted once
host write after shutdown: the host write did not reach the stopped driver
host write hook tests passed
host write over pending storage, a store recorded before a 64 KiB host write: the file's bytes survived the image's store and its texels landed around them
host write over pending storage, a store recorded before a 4 KiB host write: the file's bytes survived the image's store and its texels landed around them
host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them
host write over pending storage, a 4 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them
host write pending storage tests passed
Negative control
Both new tests call new API (HostWritesCounted, GuestArenaSetHostWriteHook_nid_no_patch), so they can't build against main's production files. I ran two narrower controls instead.
-
Only the
GuestArenaSetHostWriteHook_nid_no_patch(&GuestMemory::PrepareHostWrite)line removed fromDriver::Driver: both tests fail.agc_driver_host_write_hook: "a host write over a recorded store counted 0 call(s), 0 that waited".agc_driver_host_write_pending_storage: the same three cases fail as in the description and jotitadev's review. The whole-block case over pending results passes, as already noted there.
Output
host write over pending storage, a store recorded before a 64 KiB host write: FAILED, byte 0x0 of the file read was overwritten by the image's store after it (0x0, the file has 0x40) host write over pending storage, a store recorded before a 4 KiB host write: FAILED, byte 0x3000 of the file read was overwritten by the image's store after it (0x0, the file has 0x40) host write over pending storage, a 64 KiB host write over pending results: the file's bytes survived the image's store and its texels landed around them host write over pending storage, a 4 KiB host write over pending results: FAILED, byte 0x5 outside the file read holds 0x0, not the image's 0x47, so its results there never landed -
Only the two teardown lines in
Driver::stop()removed (the hook clear andStopHostWrites(1000)):agc_driver_host_write_hookfails with "a host write over a range with a recorded store reached the driver's flush hook 1 time(s) after Driver::Shutdown".
After the controls I restored the merged files and rebuilt. git status --porcelain is empty, and the tests above pass again.
Findings
Blocking
None.
Non-blocking
- Duplicate include (
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp:16): the PR adds#include "prx/libc/include/GuestArena.hpp", butmainalready includes it two lines below (line 18). The duplicate is left over from the merge with #6641'sShaderDiskCache.hppinclude. It does no harm, but the PR's line can be dropped. - The "Unblocks" line has no Game bring-up discussion: CONTRIBUTING asks for the title ID and its Game bring-up discussion. The line gives PPSA15657 and PPSA08240, but no discussion numbers. Separately, the description itself says the Epic Mickey crash no longer reproduces on current
main. Only the Alone in the Dark pair onmainb1f023d (3 of 6 without, 6 of 6 with) is current evidence, so the Unblocks claim rests on that title. hostWritesStoppedis never reset (core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp,StopHostWrites): this is correct today, sinceDriver::Get()is a function-local static andstop()is final. If the driver ever restarts afterShutdown, though, the hook would be registered again but return at once. Worth keeping in mind if restart support is added.
Not verified
- Hardware GPUs (only lavapipe here), Windows and macOS (the
OwnHostWriteimport window is__APPLE__-only), and any title. The title results are the reporters' runs, quoted in the description and discussion. - Only the default write-watch mode on this machine (userfaultfd, user mode only). I did not run the root or
APS5_NO_WRITE_WATCH=1modes. - The
--costtiming claim (75–90 ns on the fast path). agc_driver_graphicstook 36 s here, under parallel load. This PR doesn't change that test, and I didn't compare its time withmain.
✅ AMD GPU test: passedPR head
Unstable on main (6, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (13, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 764 tests)Skipped (60)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
✅ AMD GPU test: passedPR head
Unstable on main (5, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (13, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 807 tests)Skipped (62)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
✅ NVIDIA GPU test: passedPR head
Unstable on main (4, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (2, not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (9 IDs in 808 tests)Skipped (59)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
BunnyFl
left a comment
There was a problem hiding this comment.
@EagleBearerYS re-checked at 75ffc81473. The only new commits are merges of main. git range-diff from 59a6f5e41e, the head I approved, shows all six of your commits unchanged.
On 75ffc81473 merged onto main 78e4248fea (Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, driver 32.0.32015.12012), ctest -V with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: agc_driver_host_write_hook and agc_driver_host_write_pending_storage pass, 2 of 2, and the hook's GPU path ran again ([hostwrite] 2 host writes, 1 waited for GPU work over their range). No missing-layer line and no VUID- message. As in my first review, a runtime negative control can't be built here: the tests use HostWritesCounted, which main doesn't have.
check_conventions.py passes. pr_overlap.py --branch finds no shared exports; #8707 shares lines in docs/dev/debt/libSceAgcDriver.md, and 60 PRs that conflict with main couldn't be compared.
Approving again at 75ffc81473.
AI-assisted: yes (Claude Code)
|
Re-checked at 75ffc81: the commits since the last review are merges of |
|
@adriadam10 @EagleBearerYS a report from a bisect on PPSA15304 (Linux, NVIDIA). Not a revert request: I know this fixed a real loss for PPSA15657. Since this merge PPSA15304 dies in about half of its boots: one or two presents, then SIGSEGV (SEGV_MAPERR, a null pointer fault) in the title's own code on a title thread, 80 to 140 s in, while the main thread is in sceKernelUsleep. 170 s runs, same machine:
The two older builds carry the Ajm fix from #16974 in the working tree, which the title needs to get this far. So the host write hook is needed for the crash. What inside it goes wrong I have not shown. My guess is that the wait in FlushGpuWrites, or the write-back of pending storage, races a title thread that uses the same range. I can log the host writes of a bad run (range, calling thread, what was written back) if that helps to narrow it. |
|
@oneandonlydean thanks for the bisect. The A/B with only the hook registration removed narrows it a lot. Reading the hook on
So a title thread that reads those bytes later, such as a file read buffer, can get the GPU's older data. I can't tell from the code alone whether that is what METAL GEAR SOLID Δ: SNAKE EATER (PPSA15304) hits. A null-pointer fault on a title thread would fit it, though. Mouhand-Kaddo's #17787 (with JJenkx) addresses that race:
These titles had a crash bisected to #6926 that #17787 or
moong15 posted a matching bisect on #17787 today for Stellar Blade (PPSA13197), on Windows with an RX 9070 XT (comment):
Could you run PPSA15304 on f86ca3f with If neither clears it, your host-write log would help. These would tell the two ideas apart:
If the faulting pointer was read from a 64 KiB unit that a publish copied over after the host write, it's this race. If no publish touches those bytes, the wait or the write-back ordering is the next place to look. |
…dow fix lands Fork only. Since boykopovar#6926 the hook flushes pending GPU results over every host write; Stellar Blade's loader then reads clobbered package summaries and crashes in about 85% of launches (0 of 8 with the hook off, 2026-11-14). Drop this commit once boykopovar#17787 or another fix is on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
A host write into guest memory doesn't wait for the GPU writes recorded or in flight over the same memory, and doesn't store the storage-image results still pending there.
GuestArena::HostWritescope. That covers the APR read (libkernel/Apr/src/Apr.cpp:159-170), AIO,read/pread/readv,recv/recvfromin libkernel and libSceNet, thefcntl/ioctloutputs, libc's file reads and WebKit'smkstemp.GuestWriteWatchBeginHostWriteis Apple-only.Why that loses data: a storage image's write-back into host-imported guest memory is recorded, not made, while a recorder is active.
StorageTexture::writeBackLayers(Graphics/src/Texture.cpp) decides which 64 KiB blocks to keep for the CPU, records the retile and the copy into the open batch, and notes a pending write. The bytes land when that batch runs.Related: #6636, where the crash below was traced; #6234, the read direction (pending GPU results flushed before file writes), whose hook this one pairs with.
The title. Epic Mickey: Rebrushed (PPSA15657, UE 4.27) crashes now and then while it loads its first level. johnmaia ran it on Linux, RX 7600 (RADV, Mesa 25.2.8), on
main5d9dcc4 + #6236 with no other changes (#6636, comment):APS5_STORE_AT_FLIP=1ObjectSerializationErroronSM_MachineSet_01b(UE's "Serial size mismatch");LowLevelFatalError [Line: 1609]right after the title opens/savedata0/ue4savegame.dpx.sav;main, about 2 runs in 5 crash this way. In those, a 64 KiB block of file data the title had just read is zeroed about 18 ms after the read, with no CPU write path of the driver involved (#6636, comment).APS5_STORE_AT_FLIP=1stores pending results at every flip, which closes that window. This PR closes it at the host write itself.mainfrom 2026-10-24 the crash no longer shows without this PR either (johnmaia's follow-up); johnmaia names fix(agc): keep storage image results recorded after a direct write when its completion stamps it again #8126 and fix(agc): sync a host read on a store recorded after its snapshot check #8751, merged on 10-23, as plausible changes that cover the same path.The fix:
GuestArenaBeginHostWrite_nid_postfixnow calls a hook first, on every platform, for every non-empty range. The setter isGuestArenaSetHostWriteHook_nid_no_patch, so everyHostWriteuser above gets it with no change at the call site.GuestMemory::PrepareHostWriteinDriver::Driverand clears it in~Driver.PrepareHostWritecallsFlushGpuWritesunderReadSiteScope(ReadSite::Store), as the driver's own guest stores (GuestMemory::Write,WriteChanged) already do. That call:GuestArena.cpp).Driver::stop()now clears it first, before the worker joins, then sets a stopped flag and waits up to 1 s for calls already inside the hook to leave.PrepareHostWritecounts itself in flight (seq_cst) before it checks the flag and returns at once if it is set, so either a call sees the flag orstop()sees the call. The wait is bounded because on WindowsExitProcesscan end a thread inside the hook before~Driverruns; if the bound expires,stop()logs it and goes on.~Driverstill clears the hook as before.HostWritescope under the tracker lock, so it skips the hook through a thread-local guard and can't re-enter the tracker.g_mutexbefore itsHostWrite.DescriptorControl'slockis the guest record-lock struct, not a mutex.GuestMemory::LockedHostWrites) and logged once with its thread, address and size, then goes on. WithAPS5_ASSERT_GPU_LOCK=1, the switchAssertGpuLockHeldalready reads, it aborts with a[lock] ASSERT:line instead. It doesn't throw in a normal run: with the mutex held, the hook takesFlushForAccess's nested locked wait, which hangs only if completing needs another thread to take the GPU mutex, so a throw would turn a possible hang into a certain crash. The debt file states the rule.docs/dev/debt/libSceAgcDriver.md) narrowsmain's late-store sentence (agc-driver: write-back drops GPU results of full 64 KiB blocks of 1920x1080 render targets (PPSA12544 backgrounds garbled) #1970) to the title's own CPU stores, which still aren't ordered after a recorded store: they survive only in the 64 KiB blocks the write watch saw written. Its CPU reads after a label still read stale memory.Cost: the hook adds about 75-90 ns to a 64 KiB host write with nothing to wait for (82.5-97.7 ns against 6.9-7.1 ns, the test's
--costmode). That's the flush hook's fast path, well under theread()it precedes.APS5_PROFILE_DRAW=1, a[hostwrite]line every 10 s counts the host writes, those that waited for GPU work over their range, and the total and longest wait, e.g.[hostwrite] 2 host writes, 1 waited for GPU work over their range: 1.34 ms in total, 1.34 ms at most. Without the switch nothing is counted. The title's numbers aren't measured yet.How:
fix(agc): land GPU writes over guest memory before a host write into it: the hook, the driver's registration, the debt entry and the new testagc_driver_host_write_pending_storage(tests/execution/HostWritePendingStorage.cpp)._readFiledoes it,std::ifstream::readinside aGuestArena::HostWritescope. A laterFlushGpuWritesplays the guest's read.refactor(agc): name the host write hook as a pair to the host read hook: names the setter and the driver function after fix(libs): flush pending GPU results before file writes #6234's host read hook (GuestArenaSetHostReadHook_nid_no_patch,PrepareHostRead). The_nid_no_patchsuffix follows CONTRIBUTING.md for helper symbols that must not become NIDs.Tested
Epic Mickey: Rebrushed (PPSA15657), johnmaia's runs: Linux, RX 7600 (RADV, Mesa 25.2.8), short runs to the first level,
APS5_STORE_AT_FLIPunset (#6636, comment). Currentmainrarely shows the crash, so they ran the fix on the base where it fails:main5d9dcc4 + fix(libScePlayGo): let users answer unlisted chunks #6236maine751dd2ObjectSerializationError, theLowLevelFatalError [Line: 1609]or the SIGSEGV.APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1), 23 APR reads were each followed at once by the hook storing a pending image over their destination, before the read's bytes were written:PrepareHostWritestill callsFlushGpuWritesover the written range.Alone in the Dark (PPSA08240, v1.00), LeoFeitosa's runs (comment): Windows 11 (26200), RTX 5070 Ti (driver 617.42), WinLibs GCC 15.2.0, Release.
APS5_PLAYGO_UNLISTED_CHUNKS=installed, and has no input until the main menu.maincd700femain+APS5_STORE_AT_FLIP=1main, all while loading:LowLevelFatalError [Line: 3230], "Serial size mismatch" on UI textures;0xc000001donFAsyncLoadingThread;0xc0000005atAlone in the Dark.exe+0x20ec0bc.0xc0000005at+0x20ec0bc. Whether it shares the cause isn't traced.APS5_TRACE_APR=1 APS5_TRACE_FLUSH=1all reached the main menu, so this PR (2c5b772; the head since only mergesmain) has reached it in 13 of 14 runs (comment). The tracing changes the timing, so those eight runs don't rule the remaining crash out.Linux (lavapipe, Mesa 25.2.8, gcc 13.3, CI's Linux configure), on main 66e290f. Each check ran in all three write-watch modes: userfaultfd user-mode only (unprivileged), full userfaultfd (root), and unwatched (
APS5_NO_WRITE_WATCH=1).ctest -R '^agc' --parallel 4 --timeout 120: 625/625 at the head, 43 skipped as expected.ctest -R 'guest|libc|kernel': the same as main on that machine. The 5 failures are IPv6 tests the container always fails.GitHub runners (run 38952984815), with only the registration reverted for the red:
guest_kqueuefails there with and without the change.Merged with fix(libs): flush pending GPU results before file writes #6234 (0f5651f) and with fix(agc): cache inaccessible guest pages #6184 (4a96406), each on its own, on lavapipe. The new test passes 10/10 on both merges.
agc_driver_storage_file_writepasses 10/10 and^agc626/626.agc_driver_graphicspasses 10/10 and^agc624/625. The one failure isagc_driver_preparation_scope_settle, which passes 5/5 alone.Windows code: MinGW
-fsyntax-onlyofGuestMemory.cpp,Lifecycle.cpp,GuestArena.cppand the test: 0 errors.The review follow-ups (Linux, lavapipe, CI's configuration), each with its case in the new
agc_driver_host_write_hook, in the same commit as its change:Driver::Shutdown, a host write over a range with a recorded store must not reach the driver's flush hook. Red at the previous head: "a host write over a range with a recorded store reached the driver's flush hook 1 time(s) after Driver::Shutdown".APS5_ASSERT_GPU_LOCK=1the test aborts at the[lock] ASSERT:line, as intended.agc_driver_host_write_hookandagc_driver_host_write_pending_storagepass 20/20 in each of the three write-watch modes, and^agcpasses 626/626.^agcsweeps' only failures areagc_driver_preparation_scope_settleon Linux, a timing check under parallel load, andagc_driver_pm4_replay_tool(0xc0000139) on Windows, which fails onmainthere too.AMD Radeon 780M (RDNA 3, AMD driver 25.10.20.01), Windows 11 (WinLibs GCC 15.2.0, Release), run by keravyn-ops at 276f67d (comment):
agc_driver_host_write_hookandagc_driver_host_write_pending_storagepass.NVIDIA GeForce RTX 3080 (NVIDIA 617.42), Windows 10 Pro 22H2 (WinLibs GCC 15.2.0, Release), run by TheSovietWaffle at 276f67d (comment):
agc_driver_host_write_hookandagc_driver_host_write_pending_storagepass 5 of 5 runs each, and the 12guest_socket_host_write_*tests, which go through the changedGuestArenahost-write path, pass.NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 (GCC 15.2, Release), run by jotitadev at 276f67d merged onto
main12a71f3 (review): both new tests pass, 3/3 on the 3070.^agchas no new failures againstmain: 636 of 638 on the 3070, whereagc_driver_f16_fma_denormal_modesandagc_driver_fma_mix_f16_denormal_modesfail onmaintoo, and 638 of 638 on lavapipe. With only the hook's registration inDriver::Driverremoved, the same three cases fail on both devices as in the red above, and the whole-block case passes.Merged with
maincd700fe and 86b8424 (2c5b772, then 9f5745d, the head). Each conflicted only in the debt file, where both sides' entries are kept. On GitHub's runners at the head (run),agc_driver_host_write_pending_storage,agc_driver_host_write_hook,agc_driver_storage_file_writeandagc_driver_graphicspass 3 runs in a row on Linux. On Windows three of the four skip without Vulkan andagc_driver_graphicspasses. The libc and libkernel suites pass on both.Merged with
main0d078f7 (46d8f39, no conflicts), on GitHub's runners (run): in one run on Linux the^agctests pass, 711 tests: 662 pass, 49 skip, 0 fail. The libc and libkernel suites pass on both runners. On Windows, of 711^agctests 173 pass and 536 skip, since the runner has no Vulkan device; the only failures areagc_driver_pm4_replay_toolandagc_shader_replay_tool, which fail the same way on that runner for an unrelated branch (run).Merged with
main5949d8b and 5d48c62 (3080b8f, then b7794a5, the head; run).main's fix(agc): store resident linear color targets at completion points, limited to their drawn rectangles #9685 excepts drawn resident linear targets from the pending storage-image results debt entry this PR rewrites, and adds two entries after it; the merge keepsmain's opening, this PR's text,main's two entries, then this PR's host-write entry.main's fix(agc): let imports that cannot write guest memory keep the watch armed #10369 opens a watched import's host-write window only when the import may write guest memory; the merge keeps this PR'sOwnHostWritemark, thenmain's optional window. Theagc_driver_host_write_andagc_driver_linear_target_tests,agc_driver_address_passes_draw_transitions,agc_driver_graphics,agc_driver_preparation_scope_settle,agc_driver_storage_file_write,guest_kqueueandpublic_headerspass 10 runs in a row. Linux: 18 run, 17 pass, 1 skip (agc_driver_linear_target_direct_write_completion), 0 fail. Windows: 18 run, 3 pass, 15 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.LEGO Horizon Adventures (PPSA14632), run by winstrex (comment): Windows 11, NVIDIA GeForce RTX 5070 Ti (NVIDIA 591.86), warm shader cache, the same input script each run.
[hostwrite]line shows host writes landing on pending GPU work over their range in every run (4 to 60 per run).FAsyncLoadingThreadcrash withObjectSerializationError ... Serial size mismatchafter the graphics quality screen came in 2 of 2 runs onmain7ce3b1d, 1 of 6 on this PR's base 86b8424 and 0 of 7 with this PR (9f5745d). winstrex calls that not conclusive at these counts.UObjectHash.cppline 42).Epic Mickey: Rebrushed (PPSA15657) on newer
main, johnmaia's follow-up (comment): the same setup (i3-12100, RX 7600, RADV), where a run fails onObjectSerializationError/ Serial size mismatch,LowLevelFatalErroror a crash before the level.main5d9dcc4, earlier runs: 5 of 8 reach the level cleanly.main933c0e4 / bfb0806 (10-24), without this PR: 5 of 5.mainbfb0806 with fix(agc): pin the import ceiling only on memory exhaustion #8091 and fix(agc): keep buffer owners when a staged address space dissolves #10304, at about 7 fps in the level, the speed where the old failure showed: 14 of 14. johnmaia puts the chance of 14 clean runs at about 0.1 % if the old 3 of 8 still held.mainthis crash no longer shows a failure this PR fixes. The Alone in the Dark (cd700fe) and LEGO Horizon Adventures (7ce3b1d) runs above were also onmainfrom before fix(agc): keep storage image results recorded after a direct write when its completion stamps it again #8126 and fix(agc): sync a host read on a store recorded after its snapshot check #8751.Alone in the Dark (PPSA08240) on current
main, LeoFeitosa's rerun (comment):mainb1f023d (10-25) without this PR, the same harness (Windows 11 26200, RTX 5070 Ti, driver 617.42,APS5_PLAYGO_UNLISTED_CHUNKS=installed, the exe and.guest.prxrelinked with this build's relinker).LowLevelFatalError [Line: 3230]"Serial size mismatch" on a loading-screen texture, and two crash in the async loader right after the menu (0xc0000005onFAsyncLoadingThread, andLowLevelFatalError [Line: 197]allocating 34043592704 bytes).main, unlike Epic Mickey.libSceAgcDriver.prxchecked against the package), 6 of 6 runs reach the main menu with no fatal error (menu at 260, 90, 90, 90, 90 and 90 s) (comment).LEGO Horizon Adventures (PPSA14632) on current
main, winstrex's pair (comment): Windows 11 (26300), RTX 5070 Ti (driver 621.01). Onmainabed035 all 12 runs, with and without this PR, stopped 19 to 40 s in on the refusal from GTA V (PPSA04264) stops when the save loads: compute shader reads or writes a converted float image with 16-bit data #11425 (a compute shader reading or writing a converted float image with 16-bit data), so both sides had fix(shader): load and store 16-bit data of converted packed images #11580 merged, which fixes it. 240 s per run, alternating, with the saves and a warm shader cache restored before each run.mainabed035 + fix(shader): load and store 16-bit data of converted packed images #11580: 6 of 6 reached the load after the graphics quality screen, with noSerial size mismatchorFAsyncLoadingThreadcrash.VK_ERROR_DEVICE_LOSTat 81 s, which winstrex also saw once without this PR, in a warm-up run that isn't counted.tools/check_conventions.py: passed.Overlap. On main 1b1f848, the overlap check finds three open PRs that conflict with this one. 37 others that touch the same files conflict with main themselves, so they couldn't be checked.
GuestArena.hppandGuestArena.cpp, and the debt entry, which both PRs rewrite. Each resolves by keeping both sides.FlushGpuWrites.GuestArenaWriteWatched_nid_postfix.GuestArenaBeginHostWrite, so the two compose independently.Execution/src/Driver/Lifecycle.cpp. Whichever lands second takes a one-line merge.main32b7331 andmainwith b7794a5 merged (clean), the sameapp.exe, save state and pad script, runs alternated, 125 s from launch through the New Game load, 6 runs each. Onmain, 4 stop at the fix(agc): save the guest bytes of results that become pending over a surface that is no longer fully write-watched #7048 refusal at about 20 s, 1 on an access violation before the menu, and the one that reached the New Game load crashed there (Serial size mismatch). With this PR, 2 are clean, 2 stop at the fix(agc): save the guest bytes of results that become pending over a surface that is no longer fully write-watched #7048 refusal and 1 on an access violation before the menu; of the 3 that reached the load, 1 crashed there (anFAsyncLoadingThreadaccess violation). So the loader crash still occurred once with this PR. He notes that the rate drifts a lot with the state of the machine, so counts this small are only indicative.APS5_PLAYGO_UNLISTED_CHUNKS=installed, 60 s from boot. The title sometimes crashes during its first load, with a UE4 "Serial size mismatch" LowLevelFatalError or a SIGSEGV in package loading. JJenkx traced it with local read diagnostics that aren't in any PR. The file reads match the pak, but the failing exports are read into memory that held one of the title's colour targets about a second earlier, and the driver's idle store then writes that target's drawn rectangle over the file data (5.6 ms after the read, in the logged crash). This PR's host-write hook stores the pending target before the read.main1e24993 crashed in 5 of 12 runs, andmainwith this PR at 75ffc81 in 0 of 12 (one-sided Fisher p ≈ 0.019). The write-backs over the failing buffers within 300 ms of each read were 47 idle stores onmain, 26 of them after the read, and with this PR 4 stores by its hook before the read, 1 idle store and none after.maincrashed in about 1 run in 5, but in this paired series both arms ran 0 of 12, so those runs say nothing either way.main263eee0 (run). thuanquang's perf(agc): create the host import of a linear color target in registered memory #9879 adds a "Linear color targets" entry todocs/dev/debt/libSceAgcDriver.mdwhere this PR adds its "Host writes into guest memory" entry; the merge keeps both, and this PR's changed lines are the same.agc_driver_host_write_hookandagc_driver_host_write_pending_storage, with the tests for the files the merge changes, pass 10 runs in a row. Linux: 326 run, 316 pass, 10 skip (seven AGC tests on lavapipe and three video-out tests with no display or Vulkan device), 0 fail. Windows: 344 run, 256 pass, 88 skip (85 AGC tests, this PR's two among them, and the same three video-out tests, no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (145 and 212) and on Windows (174 and 233). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.mainfacac6a (run). The one conflict was the include block ofGuestMemory.cpp, wheremainnow has the<thread>include this PR added and adds<system_error>next to it; the merge keepsmain's lines, and this PR's other changed lines are the same.agc_driver_host_write_pending_storage,agc_driver_host_write_hook,agc_driver_graphics,agc_driver_linear_target_direct_write_completion,agc_driver_preparation_scope_settleandagc_driver_storage_file_writeran 10 times in a row with no failure. Linux: 6 run, 5 pass, 1 skip, 0 fail. Windows: 6 run, 1 pass, 5 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (166 and 264). On Windows libc passes (194), and libkernel has 4 failures of 286.guest_raise_exceptionaborted with 0xc0000409 after "address waking round 37: the handler did not run within 5 s". Run again on this commit (run) it aborted the same way at round 7, and so didmain9fc181d in the same verify setup (run, round 5). That is libkernel (Windows): guest_raise_exception slowed about 3x and sometimes aborts at "address waking" since 540364a24 (#10666) #11813, which traces it to fix(libkernel): deliver a raised exception at the guest return of a thread in host code #10666 onmain; this PR doesn't touch libkernel. The other three,exec_arguments,guest_timed_join_import_libkernel_sysandguest_timed_join_import_libkernel_web, fail at their setup in the verify's Windows build (FileNotFoundErrorstarting the title, or copying the libraries they load), and pass inmain's own Windows job at 1829def (job). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.mainba62780 (run, validation run).docs/dev/debt/libSceAgcDriver.md. Gonic0's perf(agc): trap CPU reads of label readbacks on macOS instead of storing them #13499 (label read traps, macOS) adds a "Label read traps" entry right after the "Pending storage-image results" entry this PR rewrites, and perf(agc): trap label reads of small images inside pending large ones on macOS #13678 has since changed it. The merge keeps this PR's Pending entry, thenmain's Label read traps entry, each unchanged. The other files merged on their own, and this PR's diff againstmainis the same as before in every file.maine67cc81, result):GuestArenaBeginHostWritecalls this PR's host-write hook first, which stores a trapped image whole and releases its trap. Only then does the write watch'sBeginHostWriteresolve any trap left on the range and open the pages. On Linux every trap path is under#if defined(__APPLE__), so only this PR's path is compiled there.agc_driver_host_write_pending_storageandagc_driver_host_write_hook, withagc_driver_graphics,agc_driver_linear_readback_label_off,agc_driver_linear_target_direct_write_completion,agc_driver_preparation_scope_settle,agc_driver_storage_file_writeandagc_recorder_completion_labels. Linux: 8 run, 7 pass, 1 skip, 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 208 and 308 tests on Linux and 235 and 330 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.VERIFY_VALIDATION=1on GitHub's Linux runner,mainagainst this head, the same tests wheremainhas them): both pass. The loader insertedVK_LAYER_KHRONOS_validation9 times onmainand 13 with this head, and neither log haswas not found. Both report onlyVUID-VkDeviceCreateInfo-pNext-pNext, so the change adds none.main's 985 characters to 1,396, overcheck_conventions.py's 1,000-character warning, and described the new ordering. It's nowmain's entry with only the late-store sentence narrowed to a title's own CPU stores, 993 characters. Docs only:check_conventions.py --base ba627802e2passes with no warnings.main3c3b3cd (run). The one conflict was indocs/dev/debt/libSceAgcDriver.md: this PR's narrowed "Pending storage-image results" entry and its "Host writes into guest memory" entry sit besidemain's new active-recorder entry and two write-watch entries, and the merge keeps all of them. This PR's diff overmainis unchanged. This PR'sagc_driver_host_write_pending_storageandagc_driver_host_write_hook, withagc_driver_graphics,agc_driver_linear_readback_label_off,agc_driver_linear_target_direct_write_completion,agc_driver_preparation_scope_settle,agc_driver_storage_file_writeandagc_recorder_completion_labels, ran 10 times with no failure. Linux: 8 run, 7 pass, 1 skip (agc_driver_linear_target_direct_write_completion), 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.mainb611e63 (×10, everyagctest), which brings mrfelek's perf(agc): keep moved read-only draw inputs within the draw snapshot cap #15783 (moved read-only draw inputs kept within the draw snapshot cap).docs/dev/debt/libSceAgcDriver.md, where perf(agc): keep moved read-only draw inputs within the draw snapshot cap #15783 extends the "Draw input snapshots" entry next to this PR's narrowed "Pending storage-image results" entry. The merge keeps both. The code merged without conflicts,GuestMemory.cppandGuestArena.cppincluded, whichmainchanged since 3c3b3cd. This PR's diff overmainis unchanged.agc_driver_host_write_pending_storageandagc_driver_host_write_hook, withagc_driver_graphics,agc_driver_linear_readback_label_off,agc_driver_linear_target_direct_write_completion,agc_driver_preparation_scope_settle,agc_driver_storage_file_writeandagc_recorder_completion_labels. Linux: 8 run, 7 pass, 1 skip (agc_driver_linear_target_direct_write_completion), 0 fail. Windows: 8 run, 1 pass, 7 skip (no Vulkan device), 0 fail.guest_kernel_stack_protectfailed once (GuestKernelStackProtect failed at line 276, themprotectof the test's own host pages). This PR changes no libkernel code, and in theagcrun the same head's libkernel suite passed all 329. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.agctest, once: Linux: 1,334 run, 1,247 pass, 85 skip, 2 fail. Windows: 1,373 run, 411 pass, 962 skip (no Vulkan device), 0 fail. Both failures aremain's:agc_driver_image_gather_volume("the vertex shader was not emitted in the device's module form") fails the same way inmain's ownlinuxcheck on 638187d, the fix(agc): allocate the sampled depth shadow through the image allocator #15855 merge (job). JJenkx's test(agc): expect the 3D gather vertex shader in specialized form, as #14265 emits it #15875, merged after b611e63, updates the test for the specialized vertex form perf(shader): emit vertex modules specialized instead of in registration form #14265 emits.agc_driver_pipeline_journal's 120-second timeout (778/1334 Test #1431: agc_driver_pipeline_journal ***Timeout 120.06 sec),main's own cold run.mainb611e63, Mesa 25.2.8, Ubuntu 26.04.1, 3,899 of 3,946 tests selected. 3,819 passed, 18 failed and 62 skipped. None of the failures is new: 13 also fail onmain, and 5 are unstable onmain. WithVK_LAYER_KHRONOS_validation, there are no new validation IDs againstmain, over 1,391 tests on the GPU.mainacac7c8, driver 595.99.02, Ubuntu 26.04.1, 3,913 of 3,960 tests selected. 3,848 passed, 6 failed and 59 skipped. None of the failures is new: 2 also fail onmain, and 4 are unstable onmain. WithVK_LAYER_KHRONOS_validation, there are no new validation IDs againstmain, over 1,399 tests on the GPU.git range-difffrom 59a6f5e shows this PR's six commits unchanged. On this head merged ontomain78e4248, Windows 11, AMD Radeon RX 9070 XT (driver 32.0.32015.12012), WinLibs GCC 15.2.0, Release, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1and the validation layer:agc_driver_host_write_hookandagc_driver_host_write_pending_storagepass, 2 of 2, the hook's GPU path ran ([hostwrite] 2 host writes, 1 waited for GPU work over their range), and there's noVUID-message.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.mdfiles or images added to the repository (attach them to this PR)main(LeoFeitosa: onmainb1f023d, the main menu with no fatal error in 3 of 6 runs without this PR and 6 of 6 with it; earlier, 13 of 14 runs with this PR and 1 of 6 onmaincd700fe). It has no Game bring-up discussion yet. Epic Mickey: Rebrushed (PPSA15657, Disney Epic Mickey: Rebrushed (PPSA15657) on Linux #2255) was the first title: its first-level load crash from perf(agc): reuse address-based draw builds whose inputs are unchanged #6636's thread, onmain5d9dcc4 (johnmaia: 0 of 12 runs failed with the fix, 6 of 24 without), no longer reproduces onmainfrom 10-24 without this PR.