Просмотр исходного кода

k_scheduler_lock: Fix data race

TSan reports a race between the main thread and T37 during
IsLockedByCurrentThread and when it's set at the end of Lock(),
respectively. Set owner_thread to an atomic pointer to fix it.

Co-authored-by: bunnei <bunneidev@gmail.com>
lat9nq 4 лет назад
Родитель
Сommit
83b86d915a
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      src/core/hle/kernel/k_scheduler_lock.h

+ 2 - 1
src/core/hle/kernel/k_scheduler_lock.h

@@ -4,6 +4,7 @@
 
 #pragma once
 
+#include <atomic>
 #include "common/assert.h"
 #include "core/hle/kernel/k_spin_lock.h"
 #include "core/hle/kernel/k_thread.h"
@@ -75,7 +76,7 @@ private:
     KernelCore& kernel;
     KAlignedSpinLock spin_lock{};
     s32 lock_count{};
-    KThread* owner_thread{};
+    std::atomic<KThread*> owner_thread{};
 };
 
 } // namespace Kernel