From 3fc2194fd56ec6a19dad500e02efa37cf4d6813a Mon Sep 17 00:00:00 2001 From: Eladash Date: Mon, 4 Jul 2022 20:42:15 +0300 Subject: [PATCH] Savestates: Fix zombie PPU threads saving --- rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index 354dd207cc..1d86d0b698 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -43,9 +43,9 @@ void ppu_thread_exit(ppu_thread& ppu, ppu_opcode_t, be_t*, struct ppu_intrp // Deallocate Stack Area ensure(vm::dealloc(ppu.stack_addr, vm::stack) == ppu.stack_size); - if (auto& dct = g_fxo->get(); !Emu.IsStopped()) + if (auto dct = g_fxo->try_get()) { - dct.free(ppu.stack_size); + dct->free(ppu.stack_size); } if (ppu.call_history.index) @@ -110,8 +110,15 @@ void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode) ppu.state -= cpu_flag::suspend; } - while (ppu.joiner == ppu_join_status::zombie && !ppu.is_stopped()) + while (ppu.joiner == ppu_join_status::zombie) { + if (ppu.is_stopped() && ppu.joiner.compare_and_swap_test(ppu_join_status::zombie, ppu_join_status::joinable)) + { + // Abort + ppu.state += cpu_flag::again; + return; + } + // Wait for termination thread_ctrl::wait_on(ppu.joiner, ppu_join_status::zombie); }