Repository navigation
fix(agc): release host imports before the device is destroyed - #1239
Merged
adriadam10 merged 2 commits intoOct 8, 2026
Merged
Conversation
The host import registry is a function-local static that device teardown never emptied, so every import still registered kept its VkBuffer and VkDeviceMemory past vkDestroyDevice (VUID-vkDestroyDevice-device-05137 in 23 execution tests). ClearHostImports destroys the device's imports and resets the registry; ~State calls it next to ClearImageMirrors. Closes boykopovar#1236 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RNrNcixatky8U4LfC7Ew5
Without the host import release, a device created after another was destroyed freed the leftover imports through the destroyed device and the process crashed (SIGILL on NVIDIA). The teardown test now runs a second device over the same guest block once the first is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RNrNcixatky8U4LfC7Ew5
awake-devel
force-pushed
the
fix/agc-release-host-imports
branch
from
October 7, 2026 22:19
8f6ede1 to
7a33ba2
Compare
9 tasks done
Collaborator
|
Checked on Linux (main + PR): full ctest 431/431; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #1236.
VulkanDevice::State::~Statereleases the device's caches beforevkDestroyDevicebut never emptied the host import registry (Imports()inGuestBufferMemory.cpp, a function-local static). Every import still registered at teardown kept itsVkBufferandVkDeviceMemorypastvkDestroyDevice, which the validation layer reports asVUID-vkDestroyDevice-device-05137. The next device then freed them through the destroyed device's handle inrefreshImports, and that crashes: a second device importing the same block after the first was destroyed ends the process withSIGILLin the NVIDIA driver (SIGABRTunder the validation layer). In the app the device is only destroyed inDriver::Shutdown, and the replacement at the first flip keeps the old device alive (#59), so no title reaches the crash today; tests and any later device recreation do.ClearHostImports(VkDevice), besideClearImageMirrors: under the registry lock, when the registry belongs to the device, destroys each import's buffer and memory (and unmaps its alias on Windows) as the device-change path ofrefreshImportsdoes, then clearsimportsandfailed, resetsdeviceandrefreshedGenerationand bumpsepoch.~Statecalls it right afterClearImageMirrors, once the recorder (with its retired imports), the resource cache andcopiedWritersare gone.agc_driver_host_import_teardown: a device fills part of a registered guest block throughVulkanDevice::FillBuffer, which imports it; the test checks that the fill reached guest memory and that the import exists, destroys the device and checks that the registry no longer holds an import for it. A second device then does the same with the same block, the sequence that crashed. It is skipped on devices without host imports.tests/Recorder.cppbuilds its ownVkDeviceand would need the same call before itsvkDestroyDevice; it is not registered in ctest, and #1046 and #1210 rework that harness, so it is left alone here.Tested
Linux (Arch, GCC 16.2.1), GeForce GTX 1050 Ti Max-Q, NVIDIA 580.178.04.
ctest: 400/400 pass (the 399 tests ofmainand the new one).ctestunderVK_LAYER_KHRONOS_validation1.4.363.0 (core validation): 400/400 pass with no validation message. Onmainthe 23 execution tests listed in AGC: host imports are not released before vkDestroyDevice (VUID-vkDestroyDevice-device-05137) #1236 reportVUID-vkDestroyDevice-device-05137.ClearHostImportscall removed, the new test fails withthe guest block's import outlived the first deviceand the layer reports 2 leaked objects; with it, the test passes.SIGILL(exit 132), orSIGABRT(exit 134) under the layer; with it, both devices import, fill and release the block with no validation message._WIN32alias unmapping followsrefreshImportsand was not built here.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_018RNrNcixatky8U4LfC7Ew5