d3d12_xs: texture upload decommit race causes unrecoverable AV #110
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator#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?
@Trwthh on GitHub · 2026-11-22 09:51 UTC · original
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.@omonkeyz on GitHub · 2026-11-22 17:24 UTC · original
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.