Repository navigation
GPU: free memory is not the runtime's to watch (fixes a world-load deadlock under Wine) - #1849
crashbashash wants to merge 1 commit into
Conversation
A loose copy of title memory for a null address covers 0..4 MiB, and `runtime_memory` took that free memory for a view or placeholder, so the window was tracked and its blocks guarded. On Windows nothing is committed there and the guards fail. Under Wine the process heap is, its pages became read-only, and a heap write by a thread holding the guard lock (in `Tracked::take`, `writing` or the fault handler itself) faulted into the handler, which waited for that lock forever: the title stopped at the end of loading.
f2c5f1f to
de95e51
Compare
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Free memory is not the runtime's to watch (fixes a world-load…): stops the runtime treating free pages as its own — likely a crash/OOM fix on world load. Windows-only.
|
Tested on an RTX 5080, Wine 11.22, on I forced the hang by allocating plain memory at On this Wine the process heap was above 4 GiB in 13 of 13 probes, so the null window wouldn't reach it here. A gap that remains: |
runtime_memory looked at the first page only, so a range starting in a reservation with plain committed memory further in was still guarded, and a write there blocked whoever allocated it (as in free memory). Each region of the range is checked now (VirtualQuery walk); a range with any free or plain committed region is not tracked and is copied whole instead. track runs when a copy is made, not per submission. Reported by astrosteveo on Marvisak#1849.
|
Tested on Linux/Proton with an AMD RDNA4 card: without this PR, current Setup: RX 9070 XT (RDNA4), Mesa RADV, Gentoo, kernel 7.3.4, 64 GB RAM. Proton Experimental What the freeze looked like here (
With this pr the 7 |
runtime_memory looked at the first page only, so a range starting in a reservation with plain committed memory further in was still guarded, and a write there blocked whoever allocated it (as in free memory). Each region of the range is checked now (VirtualQuery walk); a range with any free or plain committed region is not tracked and is copied whole instead. track runs when a copy is made, not per submission. Reported by astrosteveo on Marvisak#1849.
A title buffer object's copy is, with VICTORY_IN_PLACE=1, the title's memory too: placed from the 64 KiB boundary at or below the buffer (views find their bytes by address), past its end by 256 bytes where the allocation has them. A placed buffer's end only needs to be committed pages, not 64 KiB. A remap drops in-place title buffers over it as well. Buffers over many separately mapped 64 KiB views (MEM_MAPPED, one allocation each) are still copied: one heap cannot span them, and tile mappings into heaps opened over process memory were not reliable under vkd3d-proton here. Measured (RTX 5080, proton-cachyos 11.0, the title loading its world, with Marvisak#259, Marvisak#177 and Marvisak#1849 on top for NVIDIA under Wine): 3,335 title buffers and 2,117 loose windows in place, none refused, no device errors; 8 large buffers (378 MB) over separate views still copied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fixes a world-load deadlock under Wine)
|
Automated triage for the maintainers.
Generated by Claude Code |
|
Thanks for testing this on NVIDIA, and for the gap. You're right: I don't know whether the title hits it either; in our runs the change made no measurable difference. AI-assisted (Claude Code). No game data attached. |
Under Wine/Proton,
mainat70564aestops at the end of loading or just after entering the world: no frames, no audio, the title idle, no GPU fault. Six of six runs here (RX 6800 XT, RADV, GE-Proton11-14). This is the cause and a one-condition fix.What happens
shadow::loose()makes a 4 MiB window copy for an address outside every known buffer. For a null address that window is0x0..0x400000, andShadow::newaskswatch::track(0, 4 MiB, true)to track it.runtime_memory(0, true)accepts it:GetWriteWatchfails, and the view test is "anything but committed private memory", which free memory (MEM_FREE) passes.VirtualProtectcalls just fail (I haven't checked on Windows). Under Wine the process heap lives there (here, heap writes faulted on guarded blocks from0x140000to0x260000), and its pages become read-only.on_write. When the faulting thread already holdsGUARDS(it allocates insideTracked::take,writing(), oron_writeitself),on_writewaits for the lock its own thread holds, forever. Audio (apu::XApuEnqueueCommand), GPU submission (Host::execute→Tracked::take) and the title's workers then queue behind it.Evidence
xmem::map_alias→watch::title_memory_remappedfaulting intoon_write→Mutex::lock_contended; others waiting inon_write(audio) andTracked::take(GPU submission).GUARDSlogged faults at0x1400d8(RtlEnterCriticalSectionon the process heap's lock) and0x1de770(ucrtbasememcpyinto the heap), with the lock taken inTracked::take,writing()andon_write. With those faults let through, the title ran 5 minutes in the world.track():0x0+0x400000fromshadow.rs:205,VirtualQuerystate0x10000(MEM_FREE).The change
runtime_memoryalso requiresState != MEM_FREE. Placeholders and views, which it is meant to accept, are reserved or mapped, never free. New testfree_memory_is_not_tracked(track(0, 4 MiB, true)isNone): it fails without the change and passes with it. All 7watchtests pass under Wine.In the title
70564ae+ the watchdog hook (#454) + three of #994's Proton commits (4828716,e5a8c2f,d469fe9), shaders and pipelines precached withtranslate --cache --pipelines, RX 6800 XT, RADV / Mesa 26.2.6, GE-Proton11-14:With it, the opening renders: sky, skyline, characters and credits, 2,500–3,600 draws per frame, 4.8–6.2 s per frame. One of the three runs ended at 5 minutes in an access violation in title code (
+0x35a4245, reading-1, no VIctory frames on the stack); the other two didn't, so I take it to be unrelated.Not tested on Windows. The change only turns away free memory, so there it should only mean fewer
VirtualProtectcalls that fail anyway.AI-assisted (Claude Code). No game data attached.