Skip to content

Commit 1ffd6ef

Browse files
authored
fix data race tsan issue (#612)
Signed-off-by: Ian Chen <[email protected]>
1 parent 27f7017 commit 1ffd6ef

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

graphics/src/VHACD/VHACD.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@
113113
#include <stdint.h>
114114
#include <functional>
115115

116+
// Local modification done by @iche033
117+
// The m_voxelHullCount variable type is changed from
118+
// uint32_t to std::atomic<uint32_t>
119+
// to fix data race issue picked up by TSAN
120+
#include <atomic>
121+
116122
#include <vector>
117123
#include <array>
118124
#include <cmath>
@@ -5965,12 +5971,12 @@ class VoxelHull
59655971
std::unordered_map<uint32_t, uint32_t> m_voxelIndexMap; // Maps from a voxel coordinate space into a vertex index space
59665972
std::vector<VHACD::Vertex> m_vertices;
59675973
std::vector<VHACD::Triangle> m_indices;
5968-
static uint32_t m_voxelHullCount;
5974+
static std::atomic<uint32_t> m_voxelHullCount;
59695975
IVHACD::Parameters m_params;
59705976
VHACDCallbacks* m_callbacks{ nullptr };
59715977
};
59725978

5973-
uint32_t VoxelHull::m_voxelHullCount = 0;
5979+
std::atomic<uint32_t> VoxelHull::m_voxelHullCount = 0;
59745980

59755981
VoxelHull::VoxelHull(const VoxelHull& parent,
59765982
SplitAxis axis,

0 commit comments

Comments
 (0)