Vulkan: `vkAllocateMemory` failure is ignored; the recorded copy then writes to an unbound resource → machine-wide GPU fault (NVIDIA Xid 31)
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Release Type: Official Release
Version: 4.3.0.2507
Platform(s): Linux/Vulkan (any Vulkan platform under VRAM pressure)
Describe the bug
Texture.CreateImage() and buffer creation in the Vulkan backend discard the VkResult of
vkAllocateMemory (visible in the IL as call + pop). When the allocation fails under
DEVICE_LOCAL exhaustion, the bind is skipped but the object is returned as if valid, and
InitializeData records vkCmdCopyBufferToImage into the never-bound image. The copy engine
resolves the destination to VA 0x0 and faults:
NVRM: Xid (PCI:0000:01:00): 31, ... MMU Fault: ENGINE CE0 HUBCLIENT_CE1
faulted @ 0x0_00000000. FAULT_PDE ACCESS_TYPE_VIRT_WRITE
This poisons the copy-engine channel machine-wide: after the fault, unrelated copy-engine
work (including backbuffer readbacks in other runs of the process) intermittently returns
zero-filled data until driver reset. We chased weeks of "random all-black screenshots" before
root-causing this.
To Reproduce
Standalone repro (~150 lines, we can attach the project): allocate device-local textures until
near VRAM exhaustion, then create one more Texture.New2D with initial data. Fires 5/5
within ~120 ms of the trigger call on RTX 4070 Ti / driver 595, with clean negative controls
(same allocation pattern without initial data never faults — allocation failure without a
recorded copy is inert).
Expected behavior
A failed vkAllocateMemory should surface as a catchable exception
(GraphicsException / out-of-memory), never as a recorded copy into an unbound resource.
Additional context
Fix shape: check the VkResult in the allocate/bind path of Texture.CreateImage /
buffer creation and throw. We shipped an app-side guard (create empty → verify the
NativeMemory bind via reflection → upload) and it eliminates the fault 2/2 under forced
exhaustion. Happy to PR the check and/or contribute the standalone repro project.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Vulkan backend at Texture.CreateImage and the buffer-creation path, then reproduce the issue under device-local VRAM exhaustion with the standalone repro described in the report. Confirm that failed vkAllocateMemory results surface as a catchable GraphicsException or out-of-memory error and that no copy is recorded for an unbound resource.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100