mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-19 20:32:15 +02:00
win-capture: Fix Vulkan race condition
This race condition is caused when one thread creates a swap chain, which calls OBS_CreateSwapchainKHR, at the same time another thread calls OBS_CreateImageView. OBS_CreateSwapchainKHR allocates swap data, publishes this into the data->swaps linked list, then initializes it. Meanwhile, OBS_CreateImageView is iterating the swaps linked list, to see if the image matches any swap chain images. Due to the order in OBS_CreateSwapchainKHR, there's no guarantee this data is initialized so it often ends up running out of bounds on the swap_images array. The fix is simply to defer the swap data publish to after init.
This commit is contained in:
parent
c0ee1e718d
commit
aa1f2dea84
@ -1796,7 +1796,6 @@ OBS_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *cinfo,
|
||||
if ((res == VK_SUCCESS) && (count > 0)) {
|
||||
struct vk_swap_data *swap_data = alloc_swap_data(ac);
|
||||
if (swap_data) {
|
||||
init_swap_data(swap_data, data, sc);
|
||||
swap_data->swap_images = vk_alloc(
|
||||
ac, count * sizeof(VkImage), _Alignof(VkImage),
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
@ -1816,6 +1815,7 @@ OBS_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *cinfo,
|
||||
swap_data->shtex_info = NULL;
|
||||
swap_data->d3d11_tex = NULL;
|
||||
swap_data->captured = false;
|
||||
init_swap_data(swap_data, data, sc);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user