You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VulkanStateTableBase::mutex_ on InsertEntry and RemoveEntry can't protect wrappers. The thread protect need more wide. Because DestroyBuffer and RemoveWrapper are different functions. CreateBuffer and CreateWrappedHandle could happen between DestoryBuffer and RemoveWrapper.
CreateBuffer -> Another thread. Create a duplicated handle value.
CreateWrappedHandle -> The new wrapper can't be added to the map because the old one hadn't removed from the map. It prints a warning, like Create a duplicated Handle: 2230487727664. This wrapper can't be written into VulkanStateHandleTable.
DestroyWrappedHandle(buffer)
Now, the map doesn't have the new wrapper. It could get a warning, like GetWrappedId() couldn't find Handle: 2230487727664's wrapper. It might have been destroyed in the following process.
The thread protect should cover between DestroyBuffer and RemoveWrapper, not only RemoveEntry.
CreateBuffer also need protect to ensurn BufferWrapper is alive.
Thread protect for CreateBuffer and DestroyBuffer. We won't see the warning and crashes. If you remove two std::unique_lock<std::mutex> lock(buffer_wrapper_lock_), you will see the warning or crashes. You might also see InsertEntry Buffer: 1745362285408, time: 1689026056657 is before RemoveEntry Buffer: 1745362285408, time: 1689026056657. https://github.com/locke-lunarg/gfxreconstruct/tree/test-thread
The text was updated successfully, but these errors were encountered:
VulkanStateTableBase::mutex_
onInsertEntry
andRemoveEntry
can't protect wrappers. The thread protect need more wide. Because DestroyBuffer and RemoveWrapper are different functions. CreateBuffer and CreateWrappedHandle could happen between DestoryBuffer and RemoveWrapper.The thread protect should cover between
DestroyBuffer
andRemoveWrapper
, not onlyRemoveEntry
.CreateBuffer
also need protect to ensurnBufferWrapper
is alive.Here is a sample code:
Using vkcube to run CreateBuffer and DestroyBuffer 10k times on different threads.
https://github.com/locke-lunarg/Vulkan-Tools/tree/thread
Thread protect for CreateBuffer and DestroyBuffer. We won't see the warning and crashes. If you remove two
std::unique_lock<std::mutex> lock(buffer_wrapper_lock_)
, you will see the warning or crashes. You might also seeInsertEntry Buffer: 1745362285408, time: 1689026056657
is beforeRemoveEntry Buffer: 1745362285408, time: 1689026056657
.https://github.com/locke-lunarg/gfxreconstruct/tree/test-thread
The text was updated successfully, but these errors were encountered: