From b976cac49dd7bbfc461802d64d467f9c5b73ce3b Mon Sep 17 00:00:00 2001 From: lat9nq Date: Tue, 5 Apr 2022 00:37:46 -0400 Subject: k_system_control: Fix data race `return distribution(gen)` is a data race between a read and a write in two threads, reported by TSan. Remove static random number generators so they aren't using the same generator. --- src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp index 8027bec00..7765e7848 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp @@ -148,9 +148,9 @@ u64 GenerateUniformRange(u64 min, u64 max, F f) { } // Anonymous namespace u64 KSystemControl::GenerateRandomU64() { - static std::random_device device; - static std::mt19937 gen(device()); - static std::uniform_int_distribution distribution(1, std::numeric_limits::max()); + std::random_device device; + std::mt19937 gen(device()); + std::uniform_int_distribution distribution(1, std::numeric_limits::max()); return distribution(gen); } -- cgit v1.2.3