From f9760b8ef2ff145d67c8faa00371aa2538cb88f8 Mon Sep 17 00:00:00 2001 From: Cody Northrop Date: Tue, 12 Jul 2016 11:43:32 -0600 Subject: layers: Don't use instance pointer after it has been destroyed In unique_objects' explicit_DestroyInstance(), the recently introduced second get_dispatch_table() was using a destroyed instance as a lookup key, failing to find an entry (since the driver controls that memory and probably freed it), and was crashing consistently on PixelC. Instead, use the instance pointer to cleanup instanceExtMap before calling down to the ICD's DestroyInstance. Additionally, use the existing VkLayerInstanceDispatchTable* instead of calling get_dispatch_table() twice. --- layers/unique_objects.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layers/unique_objects.h b/layers/unique_objects.h index 398150a6..18a07acf 100644 --- a/layers/unique_objects.h +++ b/layers/unique_objects.h @@ -192,10 +192,10 @@ 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(key); VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(unique_objects_instance_table_map, instance); instanceExtMap.erase(pDisp); + pDisp->DestroyInstance(instance, pAllocator); + layer_data_map.erase(key); } // Handle CreateDevice -- cgit v1.2.3