Describe the bug
I believe following code contains a race condition.
https://github.com/vsg-dev/VulkanSceneGraph/blob/master/src/vsg/vk/DescriptorPool.cpp#L139
{
std::scoped_lock<std::mutex> lock(mutex);
_recyclingList.push_back(dsi);
++_availableDescriptorSet;
accumulateBindings(_recycledDescriptorPoolSizes, dsi->_descriptorSetLayout, +1);
}
dsi->_descriptorPool = {};
dsi->_descriptorPool can be overwritten by thread_2 inside allocateDescriptorSet() while thread_1 has left the mutex but didn't yet perform:
dsi->_descriptorPool = {};
To Reproduce
I got one crash. Reproducing this is not easy.
Possible solution
auto keepAlive = dsi->_descriptorPool;
{
std::scoped_lock<std::mutex> lock(mutex);
_recyclingList.push_back(dsi);
++_availableDescriptorSet;
accumulateBindings(_recycledDescriptorPoolSizes, dsi->_descriptorSetLayout, +1);
dsi->_descriptorPool = {};
}
Describe the bug
I believe following code contains a race condition.
https://github.com/vsg-dev/VulkanSceneGraph/blob/master/src/vsg/vk/DescriptorPool.cpp#L139
{ std::scoped_lock<std::mutex> lock(mutex); _recyclingList.push_back(dsi); ++_availableDescriptorSet; accumulateBindings(_recycledDescriptorPoolSizes, dsi->_descriptorSetLayout, +1); } dsi->_descriptorPool = {};dsi->_descriptorPool can be overwritten by thread_2 inside allocateDescriptorSet() while thread_1 has left the mutex but didn't yet perform:
dsi->_descriptorPool = {};To Reproduce
I got one crash. Reproducing this is not easy.
Possible solution