d3d12: lazy publication gives back a page's protection from deferral time, undoing the title's later VirtualProtect (Lanes texture-publication crashes) #625
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-01T15:41:44Z.
What fails
After
e40d8052(lazy publication on by default),lanes-selftest-texture-publicationfails every time. Every other selftest passes. Found on4cc17f52; nothing inruntime/d3d12/src/device/placement/changed up tofb17e160.4cc17f52)texture-publicationTUXBOX_LAZY_PUBLICATION=0TUXBOX_READ_RESIDENCY=0TUXBOX_CHECK_ONCE_PER_FRAME=0Host: RX 6600 (1002:73ff, RDNA2), Mesa 26.3.1 RADV, GE-Proton11-15.
What happens
Exit 5 is not the scenario's own failure path, which writes a receipt and exits 1. The guest dies on an unhandled read fault. With
WINEDEBUG=+seh,+debugstr:0x37ac000(8 pages). The scenario closes its third page (0x37ae000) withPAGE_NOACCESSbefore the GPU writes. It opens the page again withVirtualProtect(..., old)after the label wait.0x37ac000, and the lazy handler publishes it (lazy publication: 1 published on access (... from lanes.exe+0x24135, nested false)). Inside that, a syscall faults on0x37ae000.0x37ae000, the page it has opened again. The read faults, the lazy handler passes it on (the page is no longer held), and nothing else handles it:Unhandled page fault on read access to 0x00000000037ae000 at lanes.exe+0x24135.Cause
lazy::defer(fromheap_writes.rs) protects every page of the texture and records each page's protection at that moment inPages::held. For the third page that isPAGE_NOACCESS, because the title had closed it.VirtualProtect. Nothing updatesPages::held.handler→publish_now→publish_texturecallslazy::release, anddrop_holdrestores the recordedPAGE_NOACCESS. That undoes the title's change, and the page stays closed after publication.For a title, this would show as an access violation in title code, not as a GPU fault.
Proposed fix (draft PR in the works)
I have a fix on a local branch:
Pages::releasestill restores each page's protection from deferral time, so the write-back sees the pages as an eager publication would have (the page the title had closed is skipped, as the scenario expects).lazy::releasewraps them in a guard.publish_textureholds the guard across the write-back and sets the title's protection again when it drops. The handler and the texture's teardown set it at once.Checks so far, on
4cc17f52:tests/device/placement/lazy.rs: a page the title reopened while held is closed during the write-back and handed back with the title's protection. It failed before the change. All 9lazytests pass (run under Wine withcargo xwin test, since CI only typechecks this crate).lanes-selftestwith lazy publication on: 3/3 runs,texture-publicationpasses and nothing else fails.tuxbox.py check --no-gpu: 13/13.Not covered: a page the title closes while it is held looks the same as one lazy publication closed (
PAGE_NOACCESS), so release would still open it again. I have nothing that reproduces that and left it out.I'd like to claim this and open the PR after a game run on current main, unless you'd rather handle it yourself, @brcly, since lazy publication is part of your frame-time work. Happy to hand over the test and the patch either way.
Imported from brcly/TuxBox. Originally posted by brcly on 2026-12-01T15:46:33Z.
Hey there,
I'm more than happy for you to handle it if you'd like.
My frametime work has just been a starting point to build on.
Being in-game at 0.1 FPS wasn't fun; however, at 2fps, it gives us a better base to work from.
I'm going to focus on shaders and compilation time, though avoiding the ray tracing work that others handling.
I'm confident that as soon as all our branches connect, we'll have a really good working bit of kit.
Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-01T16:03:18Z.
Thanks, I'll take it. I'll open the PR after a ProjectScarlett run with the fix on current main, next to the default-settings run for #603, so the two can be compared.
Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-01T22:30:53Z.
Status: the fix is ready and rebased onto main
2a850114, but I'm holding the PR until a ProjectScarlett run with lazy publication on, which on RADV first needs #640 (DrArroway's fix for #634).2a850114+ #640 + this fix. They touch different parts oflazy.rsbut conflict in two places: #640's userptr check sits right before theprotectcall this fix shortens, and #640's newpages.releasefor dead textures has to give the title's protection back at once (Reopendropped immediately). #640's new unit test needed the same adjustment. Whichever lands first, the other needs that small rebase.lanes-selftest-texture-publication. d3d12 unit tests under Wine: 577 pass (the 3scene_publicationtests need a hardware device and fail the same way on main).Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-02T06:45:56Z.
The fix is up as #647 (rebased onto main
3e2839b1, so it includes #640).Since my last status: the same Series S run on main
3e2839b1without the fix reached the world and ended after 446 s on the #603 TCP read fault, with no SQC fault. Lazy publication published nothing on access in that run. With one run each, I can't tie the SQC instruction-fetch fault from the joint run to this change. Details are in the PR.