diff options
| author | Mark Lobodzinski <mark@lunarg.com> | 2016-04-01 15:58:32 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-04-01 16:22:10 -0600 |
| commit | f7ace8cfdfa35b209d7cd2e9ea4f4773367c4dd1 (patch) | |
| tree | ffa7f9c85c1a4bd4f6521a64c98e8966c8f8d9d1 /layers | |
| parent | 1d4b952c921f331c4207d6b2745daf5e42869a24 (diff) | |
| download | usermoji-f7ace8cfdfa35b209d7cd2e9ea4f4773367c4dd1.tar.xz | |
layers: Enable safety check for invalid QueryObject
Typo allowed object access for invalid QueryToStateMap objects
Change-Id: I50845ca09564ea8b77173d2165a5318160dd8d7e
Diffstat (limited to 'layers')
| -rw-r--r-- | layers/core_validation.cpp | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 63879bc1..59a0e318 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5757,51 +5757,52 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice device, VkQueryPoo auto queryElement = queriesInFlight.find(query); auto queryToStateElement = dev_data->queryToStateMap.find(query); if (queryToStateElement != dev_data->queryToStateMap.end()) { - } - // Available and in flight - if (queryElement != queriesInFlight.end() && queryToStateElement != dev_data->queryToStateMap.end() && - queryToStateElement->second) { - for (auto cmdBuffer : queryElement->second) { - pCB = getCBNode(dev_data, cmdBuffer); - auto queryEventElement = pCB->waitedEventsBeforeQueryReset.find(query); - if (queryEventElement == pCB->waitedEventsBeforeQueryReset.end()) { + // Available and in flight + if (queryElement != queriesInFlight.end() && queryToStateElement != dev_data->queryToStateMap.end() && + queryToStateElement->second) { + for (auto cmdBuffer : queryElement->second) { + pCB = getCBNode(dev_data, cmdBuffer); + auto queryEventElement = pCB->waitedEventsBeforeQueryReset.find(query); + if (queryEventElement == pCB->waitedEventsBeforeQueryReset.end()) { + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", + "Cannot get query results on queryPool %" PRIu64 " with index %d which is in flight.", + (uint64_t)(queryPool), firstQuery + i); + } else { + for (auto event : queryEventElement->second) { + dev_data->eventMap[event].needsSignaled = true; + } + } + } + // Unavailable and in flight + } else if (queryElement != queriesInFlight.end() && queryToStateElement != dev_data->queryToStateMap.end() && + !queryToStateElement->second) { + // TODO : Can there be the same query in use by multiple command buffers in flight? + bool make_available = false; + for (auto cmdBuffer : queryElement->second) { + pCB = getCBNode(dev_data, cmdBuffer); + make_available |= pCB->queryToStateMap[query]; + } + if (!(((flags & VK_QUERY_RESULT_PARTIAL_BIT) || (flags & VK_QUERY_RESULT_WAIT_BIT)) && make_available)) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", - "Cannot get query results on queryPool %" PRIu64 " with index %d which is in flight.", + "Cannot get query results on queryPool %" PRIu64 " with index %d which is unavailable.", (uint64_t)(queryPool), firstQuery + i); - } else { - for (auto event : queryEventElement->second) { - dev_data->eventMap[event].needsSignaled = true; - } } - } - // Unavailable and in flight - } else if (queryElement != queriesInFlight.end() && queryToStateElement != dev_data->queryToStateMap.end() && - !queryToStateElement->second) { - // TODO : Can there be the same query in use by multiple command buffers in flight? - bool make_available = false; - for (auto cmdBuffer : queryElement->second) { - pCB = getCBNode(dev_data, cmdBuffer); - make_available |= pCB->queryToStateMap[query]; - } - if (!(((flags & VK_QUERY_RESULT_PARTIAL_BIT) || (flags & VK_QUERY_RESULT_WAIT_BIT)) && make_available)) { + // Unavailable + } else if (queryToStateElement != dev_data->queryToStateMap.end() && !queryToStateElement->second) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", "Cannot get query results on queryPool %" PRIu64 " with index %d which is unavailable.", (uint64_t)(queryPool), firstQuery + i); + // Unitialized + } else if (queryToStateElement == dev_data->queryToStateMap.end()) { + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", + "Cannot get query results on queryPool %" PRIu64 + " with index %d as data has not been collected for this index.", + (uint64_t)(queryPool), firstQuery + i); } - // Unavailable - } else if (queryToStateElement != dev_data->queryToStateMap.end() && !queryToStateElement->second) { - skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, - 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", - "Cannot get query results on queryPool %" PRIu64 " with index %d which is unavailable.", - (uint64_t)(queryPool), firstQuery + i); - // Unitialized - } else if (queryToStateElement == dev_data->queryToStateMap.end()) { - skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, - 0, __LINE__, DRAWSTATE_INVALID_QUERY, "DS", - "Cannot get query results on queryPool %" PRIu64 " with index %d as data has not been collected for this index.", - (uint64_t)(queryPool), firstQuery + i); } } loader_platform_thread_unlock_mutex(&globalLock); |
