From 10c81fbdf94066fc45a87bc3201fce079f5a801a Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 7 Sep 2019 20:43:16 +0300 Subject: [PATCH] Fix passive reservation locks checking at Emu.Stop() (#6482) --- rpcs3/Emu/CPU/CPUThread.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index dacf66195b..197d72004b 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -162,6 +162,11 @@ void cpu_thread::operator()() thread_ctrl::wait(); } + if (auto ptr = vm::g_tls_locked) + { + ptr->compare_and_swap(this, nullptr); + } + // Unregister and wait if necessary state += cpu_flag::wait; verify("g_cpu_array[...] -> null" HERE), g_cpu_array[array_slot].exchange(nullptr) == this; @@ -262,12 +267,12 @@ bool cpu_thread::check_state() noexcept continue; } - if (state & cpu_flag::wait) + if (state0 & cpu_flag::wait) { // Spin wait once for a bit before resorting to thread_ctrl::wait for (u32 i = 0; i < 10; i++) { - if (state0 & (cpu_flag::pause + cpu_flag::suspend)) + if (state & (cpu_flag::pause + cpu_flag::suspend)) { busy_wait(500); } @@ -277,7 +282,7 @@ bool cpu_thread::check_state() noexcept } } - if (!(state0 & (cpu_flag::pause + cpu_flag::suspend))) + if (!(state & (cpu_flag::pause + cpu_flag::suspend))) { continue; }