Skip to content

clear icd debug list slot after destroying messenger or callback - #2080

Merged
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:debug-list-slot-clear-on-destroy
Oct 23, 2026
Merged

charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:debug-list-slot-clear-on-destroy

Conversation

@aizu-m

@aizu-m aizu-m commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Found while auditing the debug messenger create rollback against terminator_DestroySurfaceKHR, which resets its per-ICD slot after the driver destroy. The debug utils and debug report destroy terminators do not. Reproduced by creating and destroying a messenger, then failing the driver's allocation on the next create into the same slot. The test driver reports:

Messenger not found during destroy!

terminator_DestroyDebugUtilsMessengerEXT calls the driver destroy on debug_utils_messenger_list.list[index] and releases the used-object slot, but leaves the destroyed handle in the list. loader_get_next_available_entry hands that index to the next vkCreateDebugUtilsMessengerEXT. The create rollback treats a non-NULL list[next_index] as a handle this call created. So a driver create that fails with VK_ERROR_OUT_OF_HOST_MEMORY on a reused slot, or a second driver failing after the first succeeded, sends the driver a handle it already destroyed. The rollback left its own destroyed handle behind in the same way.

Reset the slot to VK_NULL_HANDLE after each driver destroy, in both destroy terminators and in both create rollbacks. terminator_DestroyDebugReportCallbackEXT has the same defect and the same fix.

The test ICD now returns VK_ERROR_OUT_OF_HOST_MEMORY when the application allocator refuses its handle allocation, as a conformant driver does. Two regression tests under Allocation create and destroy a messenger or callback, then sweep allocation failures over a second create into the same slot. Both abort in the test driver before the change and pass after.

terminator_DestroyDebugUtilsMessengerEXT and
terminator_DestroyDebugReportCallbackEXT call the driver destroy on the
per-ICD list slot and release the used-object slot, but leave the
destroyed driver handle in the list. The next create is handed the same
index, and its error rollback treats a non-NULL slot as a handle this
call created, so a driver create failing on a reused slot passes the
driver a handle it already destroyed. The rollback loops left their own
destroyed handle behind in the same way.

Reset the slot to VK_NULL_HANDLE after each driver destroy, matching
terminator_DestroySurfaceKHR. The test ICD now returns
VK_ERROR_OUT_OF_HOST_MEMORY when the application allocator refuses its
handle allocation, and two regression tests cover the reused slot path.
@ci-tester-lunarg

Copy link
Copy Markdown

User aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown

User aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 169433.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3903 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3903 passed.

@charles-lunarg
charles-lunarg merged commit 9f1b344 into KhronosGroup:main Oct 23, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants