From c456d16fc7ac43fb014d9e9a25928e04671d2dc6 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 10 Aug 2020 15:24:51 +0100 Subject: [PATCH] Avoid crash if mapped memory is changed while diffing --- renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp index fd51324df..de6b3b90a 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp @@ -1147,6 +1147,14 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount, else diffEnd = (size_t)state.mapSize; + // sanitise diff start/end. Since the mapped pointer might be written on another thread + // (or even the GPU) this could cause a difference to appear and disappear transiently. In + // this case FindDiffRange could find the difference when locating the start but not find + // it when locating the end. In this case we don't need to write the difference (the + // application is responsible for ensuring it's not writing to memory the GPU might need) + if(diffEnd <= diffStart) + found = false; + if(found) { // MULTIDEVICE should find the device for this queue.