From 16579e0b1f0e20872c0b5ea628b56f0e1edcfced Mon Sep 17 00:00:00 2001 From: Eladash Date: Tue, 6 Jun 2023 03:31:15 +0300 Subject: [PATCH] Fix spu_thread::cleanup() --- rpcs3/Emu/CPU/CPUThread.cpp | 5 ++++- rpcs3/Emu/Cell/SPUThread.cpp | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 0e0a063194..7098776a53 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -1312,7 +1312,10 @@ bool cpu_thread::suspend_work::push(cpu_thread* _this) noexcept void cpu_thread::cleanup() noexcept { - ensure(!s_cpu_counter); + if (u64 count = s_cpu_counter) + { + fmt::throw_exception("cpu_thread::cleanup(): %u threads are still active! (created=%u, destroyed=%u)", count, +g_threads_created, +g_threads_deleted); + } sys_log.notice("All CPU threads have been stopped. [+: %u]", +g_threads_created); diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index af86f12b8a..06973dc2ca 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -1767,11 +1767,8 @@ void spu_thread::cleanup() // Free range lock (and signals cleanup was called to the destructor) vm::free_range_lock(range_lock); - // Signal the debugger about the termination - if (!state.test_and_set(cpu_flag::exit)) - { - state.notify_one(); - } + // Terminate and join thread + static_cast&>(*this) = thread_state::finished; } spu_thread::~spu_thread()