From 87f5368d3c9c97bd71fb4dad015adff4e58618fd Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Sun, 23 Jun 2024 18:34:18 +0300 Subject: [PATCH] PPU: Fix access violation on logging --- rpcs3/Emu/Cell/PPUFunction.h | 10 ++++++++++ rpcs3/Emu/Cell/PPUThread.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/PPUFunction.h b/rpcs3/Emu/Cell/PPUFunction.h index e9ef4321b9..f8e02f20d9 100644 --- a/rpcs3/Emu/Cell/PPUFunction.h +++ b/rpcs3/Emu/Cell/PPUFunction.h @@ -305,6 +305,16 @@ public: return addr + index * 8 + (is_code_addr ? 4 : 0); } + bool is_func(u32 cia) const + { + if (cia % 4 || !addr || cia < addr) + { + return false; + } + + return (cia - addr) / 8 < access().size(); + } + // Allocation address u32 addr = 0; diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index f0a7c11474..9668aadee9 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -2760,7 +2760,7 @@ void ppu_thread::fast_call(u32 addr, u64 rtoc, bool is_thread_entry) const auto cia = _this->cia; - if (_this->current_function && vm::read32(cia) != ppu_instructions::SC(0)) + if (_this->current_function && g_fxo->get().is_func(cia)) { return fmt::format("PPU[0x%x] Thread (%s) [HLE:0x%08x, LR:0x%08x]", _this->id, *name_cache.get(), cia, _this->lr); }