d3d12_xs: texture upload decommit race causes unrecoverable AV #110
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 omonkeyz/xbox-emulator. Originally posted by Trwthh on 2026-11-22T09:51:48Z.
Bug
In
crates/compat/d3d12_xs/src/upload.rs, the texture upload copy loop (line ~30+) reads from placed-resource backing memory that a title thread can decommit concurrently. The code documents the risk ("a decommit racing the read would fault") but has no SEH guard or VirtualQuery pre-check.On Xbox hardware this cannot happen because the GPU and CPU share unified memory with hardware-managed residency. On PC, the backing memory is a separate CPU-side buffer whose lifetime is managed by VirtualAlloc/VirtualFree, and a title that frees placed-resource memory while the uploader is mid-copy causes an access violation with no recovery path.
Impact
Intermittent crash (AV) during texture streaming, especially in titles that aggressively recycle placed-resource memory (observed as a risk during Fortnite lobby texture streaming and Terraria texture upload). Hard to reproduce because it requires a narrow race window.
Suggested fix
Wrap the copy loop in a Windows SEH
__try/__except(EXCEPTION_EXECUTE_HANDLER)(or the Rust equivalent viawindows-rsor inline asm), and treat a fault as a failed upload (fill with black or skip the mip), matching the graceful-degradation pattern already used for "upload unreadable placed texture" cases.Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T17:24:23Z.
Fixed by #153, merged in
fe391fe(commits5d5bc33and439826e). Reads of placed-texture memory now run inside a range-scoped fault guard. If the title decommits the memory while a read is in progress, the read is skipped and logged, instead of an access violation taking down the process. A fault outside the declared range still crashes as before.