diff options
| author | 2022-04-05 00:37:46 -0400 | |
|---|---|---|
| committer | 2022-04-05 19:55:56 -0400 | |
| commit | b976cac49dd7bbfc461802d64d467f9c5b73ce3b (patch) | |
| tree | c09a194cadf961f124e064725014538f0eafe8b1 | |
| parent | k_auto_object: Fix data race (diff) | |
| download | yuzu-b976cac49dd7bbfc461802d64d467f9c5b73ce3b.tar.gz yuzu-b976cac49dd7bbfc461802d64d467f9c5b73ce3b.tar.xz yuzu-b976cac49dd7bbfc461802d64d467f9c5b73ce3b.zip | |
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.
| -rw-r--r-- | src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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) { | |||
| 148 | } // Anonymous namespace | 148 | } // Anonymous namespace |
| 149 | 149 | ||
| 150 | u64 KSystemControl::GenerateRandomU64() { | 150 | u64 KSystemControl::GenerateRandomU64() { |
| 151 | static std::random_device device; | 151 | std::random_device device; |
| 152 | static std::mt19937 gen(device()); | 152 | std::mt19937 gen(device()); |
| 153 | static std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max()); | 153 | std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max()); |
| 154 | return distribution(gen); | 154 | return distribution(gen); |
| 155 | } | 155 | } |
| 156 | 156 | ||