From a85e914f78cfeff4d2defd16ee3aa9b80fbeec01 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 29 Apr 2018 09:47:39 -0700 Subject: [PATCH] Vulkan: Fix use-after-free crash on shutdown. --- ext/native/thin3d/thin3d_vulkan.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 1344af164434..6f6a7dc7356d 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -788,7 +788,12 @@ VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit) VKContext::~VKContext() { allocator_->Destroy(); - delete allocator_; + // We have to delete on queue, so this can free its queued deletions. + vulkan_->Delete().QueueCallback([](void *ptr) { + auto allocator = static_cast(ptr); + delete allocator; + }, allocator_); + allocator_ = nullptr; // This also destroys all descriptor sets. for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) { frame_[i].descSets_.clear();