Skip to content

Commit

Permalink
fix data race tsan issue (#612)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Jun 21, 2024
1 parent 27f7017 commit 1ffd6ef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions graphics/src/VHACD/VHACD.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
#include <stdint.h>
#include <functional>

// Local modification done by @iche033
// The m_voxelHullCount variable type is changed from
// uint32_t to std::atomic<uint32_t>
// to fix data race issue picked up by TSAN
#include <atomic>

#include <vector>
#include <array>
#include <cmath>
Expand Down Expand Up @@ -5965,12 +5971,12 @@ class VoxelHull
std::unordered_map<uint32_t, uint32_t> m_voxelIndexMap; // Maps from a voxel coordinate space into a vertex index space
std::vector<VHACD::Vertex> m_vertices;
std::vector<VHACD::Triangle> m_indices;
static uint32_t m_voxelHullCount;
static std::atomic<uint32_t> m_voxelHullCount;
IVHACD::Parameters m_params;
VHACDCallbacks* m_callbacks{ nullptr };
};

uint32_t VoxelHull::m_voxelHullCount = 0;
std::atomic<uint32_t> VoxelHull::m_voxelHullCount = 0;

VoxelHull::VoxelHull(const VoxelHull& parent,
SplitAxis axis,
Expand Down

0 comments on commit 1ffd6ef

Please sign in to comment.