Skip to content

Commit

Permalink
Workaround TSAN mutex issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouwe committed Sep 25, 2024
1 parent fc720ed commit 221f769
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Jolt/Physics/Body/BodyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ void BodyManager::Init(uint inMaxBodies, uint inNumBodyMutexes, const BroadPhase

// Num body mutexes must be a power of two and not bigger than our MutexMask
uint num_body_mutexes = Clamp<uint>(GetNextPowerOf2(inNumBodyMutexes == 0? 2 * thread::hardware_concurrency() : inNumBodyMutexes), 1, sizeof(MutexMask) * 8);
#ifdef JPH_TSAN_ENABLED
num_body_mutexes = min(num_body_mutexes, 32U); // TSAN errors out when locking too many mutexes on the same thread, see: https://github.com/google/sanitizers/issues/950
#endif

// Allocate the body mutexes
mBodyMutexes.Init(num_body_mutexes);
Expand Down

0 comments on commit 221f769

Please sign in to comment.