AGC: host imports are not released before vkDestroyDevice (VUID-vkDestroyDevice-device-05137) #1236
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 boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-07T18:58:42Z.
Summary
VulkanDevice::State::~Statereleases the device's caches beforevkDestroyDevice(VulkanDevice.cpp#L481-L556), the image mirrors included since #849, but not the host imports. The import registry,Imports(), is a function-local static, so every import still registered when the device is destroyed keeps itsVkBufferandVkDeviceMemorypastvkDestroyDevice. The validation layer reports it asVUID-vkDestroyDevice-device-05137.The registry frees leftover imports only when it next sees another device (
refreshImports), through the handle it stored for the old one. The replacement at the first flip is safe, since #59 keeps replaced devices alive (Presentation.cpp#L59). A process that destroys its device and then creates another would free them through a destroyedVkDevice; no test does that today.Found with AI assistance (Claude Code) while running the suite under the validation layer for #1221.
Evidence
mainatcea1ef13, Linux, GTX 1050 Ti Max-Q (NVIDIA 580.178.04),vulkan-validation-layers1.4.363.0, core validation:All 400 tests pass. 23 execution tests report one
VUID-vkDestroyDevice-device-05137each and nothing else:bvh64_intersect_ray,flat_cache_bits,flat_d16_loads,flat_loads,flat_loads_x2_x3,flat_loads_x4,flat_store,global_atomic_csub,global_atomics,global_atomics64,global_atomics_float,global_atomics_lanes,global_loads,global_loads_x2_x3,global_loads_x4,global_store_addtid,global_vcc_base,image_converted_unorm,image_srgb_load,image_store_packed,image_store_sint,scalar_wide_loadsandview_past_last_mip(allagc_driver_*).Each leaks one or two
VkBuffer/VkDeviceMemorypairs. Printing the handles at the end ofcreateImportmatches them to imports:flat_storemakes three, one of 16 KiB and two of 64 KiB, and the two 64 KiB ones are its 4 leaked objects; the 16 KiB one is released during the test.flat_loadsleaks its one 64 KiB import.Proposed fix
A
ClearHostImports(VkDevice)besideClearImageMirrors: under the registry lock, if the registry belongs to the device, destroy each import's buffer and memory (and unmap its alias on Windows), clearimportsandfailed, resetdeviceand bumpepoch.~Statecalls it right afterClearImageMirrors(L523), once the recorder, the resource cache andcopiedWriters, which can still reference imports, are gone.Tried locally: the 23 reports disappear, and the full suite passes 400/400 under the layer with no validation message.