Access violation reading location, while destroying swapchain

What all reason could result in below mentioned error while deleting oldswapchain after recreation ?
Access violation reading location 0x0000000000000020

It looks like dereferencing nullptr, resp. something 0x20 (32) bytes away from null.

Create minimal example demonstrating the shortest codepath to get you to the problem. It will either help you discover the problem, or you will have something that you can share.

So its a multi threaded submission setup. To repro, I tried recreating the swapchain just after vkAcquireNextImageKHR (resulted in the same error), adding a dummy vkQueuePresentKHR allowed the old swapchain deletion. But the same hack doesn’t fix the issue while in multi-threaded environment, wanted to understand the exact cause, is there a possibility that something is getting deleted when the swapchain goes out of order. Will try to give a repro code.

So if the resize is caught when the submission thread is presenting (vkQueuePresentKHR), the vkDestroySwapchainKHR gives the access violation error. Although if it gets caught while acquiring VkAcquireNextImageInfoKHR it doesn’t throw the above mentioned error.

Used a data breakpoint to verify the content modification for the swapchain variable, there also no issue found.

Any idea what could cause this ?

Well, obviously, you must not destroy a swapchain you are currently using in another thread.