From: Mark Lobodzinski Date: Thu, 17 Nov 2016 17:56:14 +0000 (-0700) Subject: layers: GH949, Fix ObjTrkr to destroy NULL handles X-Git-Tag: upstream/1.1.92~2141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d9457719304bd4fae2db1f9e945f608258e5b9f;p=platform%2Fupstream%2FVulkan-Tools.git layers: GH949, Fix ObjTrkr to destroy NULL handles ObjectTracker emitted errors when a destroy/free call was made with VK_NULL_HANDLE, which *is* allowed by the spec. Change-Id: I2b4e19999e539d68b5856139566d4a7a8a530ca6 --- diff --git a/layers/object_tracker.cpp b/layers/object_tracker.cpp index 4408c14..172d81e 100644 --- a/layers/object_tracker.cpp +++ b/layers/object_tracker.cpp @@ -280,37 +280,39 @@ static void DestroyObject(T1 dispatchable_object, T2 object, VkDebugReportObject auto object_handle = handle_value(object); bool custom_allocator = pAllocator != nullptr; - auto item = device_data->object_map[object_type].find(object_handle); - if (item != device_data->object_map[object_type].end()) { + if (object_handle != VK_NULL_HANDLE) { + auto item = device_data->object_map[object_type].find(object_handle); + if (item != device_data->object_map[object_type].end()) { + + OBJTRACK_NODE *pNode = item->second; + assert(device_data->num_total_objects > 0); + device_data->num_total_objects--; + assert(device_data->num_objects[pNode->object_type] > 0); + device_data->num_objects[pNode->object_type]--; + + log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, pNode->object_type, object_handle, __LINE__, + OBJTRACK_NONE, LayerName, + "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", + object_name[pNode->object_type], reinterpret_cast(object), device_data->num_total_objects, + device_data->num_objects[pNode->object_type], object_name[pNode->object_type]); + + auto allocated_with_custom = (pNode->status & OBJSTATUS_CUSTOM_ALLOCATOR) ? true : false; + if (custom_allocator ^ allocated_with_custom) { + log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle, __LINE__, + OBJTRACK_ALLOCATOR_MISMATCH, LayerName, + "Custom allocator %sspecified while destroying %s obj 0x%" PRIxLEAST64 " but %sspecified at creation", + (custom_allocator ? "" : "not "), object_name[object_type], object_handle, + (allocated_with_custom ? "" : "not ")); + } - OBJTRACK_NODE *pNode = item->second; - assert(device_data->num_total_objects > 0); - device_data->num_total_objects--; - assert(device_data->num_objects[pNode->object_type] > 0); - device_data->num_objects[pNode->object_type]--; - - log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, pNode->object_type, object_handle, __LINE__, - OBJTRACK_NONE, LayerName, - "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", - object_name[pNode->object_type], reinterpret_cast(object), device_data->num_total_objects, - device_data->num_objects[pNode->object_type], object_name[pNode->object_type]); - - auto allocated_with_custom = (pNode->status & OBJSTATUS_CUSTOM_ALLOCATOR) ? true : false; - if (custom_allocator ^ allocated_with_custom) { - log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object_type, object_handle, __LINE__, - OBJTRACK_ALLOCATOR_MISMATCH, LayerName, - "Custom allocator %sspecified while destroying %s obj 0x%" PRIxLEAST64 " but %sspecified at creation", - (custom_allocator ? "" : "not "), object_name[object_type], object_handle, - (allocated_with_custom ? "" : "not ")); + delete pNode; + device_data->object_map[object_type].erase(item); + } else { + log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, object_handle, __LINE__, + OBJTRACK_UNKNOWN_OBJECT, LayerName, + "Unable to remove %s obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", + object_name[object_type], object_handle); } - - delete pNode; - device_data->object_map[object_type].erase(item); - } else { - log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, object_handle, __LINE__, - OBJTRACK_UNKNOWN_OBJECT, LayerName, - "Unable to remove %s obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", - object_name[object_type], object_handle); } }