From 0737226d2170be53c4e14aa3968d4386c7201c32 Mon Sep 17 00:00:00 2001 From: Dustin Graves Date: Fri, 29 Apr 2016 11:55:43 -0600 Subject: layers: Fix access violation Move the get_dispatch_key(instance/device) call before calling the driver's vkDestroyDevice/vkDestroyInstance functions in unique_objects. This addresses an access violation error reported by Application Verifier on Windows due to the previously destroyed instance/device handle being dereferenced. Change-Id: I151d42fb8a897d9d3b3c988813108b0b6b5b6b0d --- layers/unique_objects.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/layers/unique_objects.h b/layers/unique_objects.h index 0479e581..e2854508 100644 --- a/layers/unique_objects.h +++ b/layers/unique_objects.h @@ -166,8 +166,9 @@ VkResult explicit_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const } void explicit_DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { + dispatch_key key = get_dispatch_key(instance); get_dispatch_table(unique_objects_instance_table_map, instance)->DestroyInstance(instance, pAllocator); - layer_data_map.erase(get_dispatch_key(instance)); + layer_data_map.erase(key); } // Handle CreateDevice @@ -219,8 +220,9 @@ VkResult explicit_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *p } void explicit_DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { + dispatch_key key = get_dispatch_key(device); get_dispatch_table(unique_objects_device_table_map, device)->DestroyDevice(device, pAllocator); - layer_data_map.erase(get_dispatch_key(device)); + layer_data_map.erase(key); } VkResult explicit_CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, -- cgit v1.2.3