vm: Deallocate memory early, check no PS3 memory leaks
Some checks are pending
Generate Translation Template / Generate Translation Template (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux-aarch64.sh, gcc, rpcs3/rpcs3-ci-jammy-aarch64:1.6, ubuntu-24.04-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.6, ubuntu-24.04) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.6, ubuntu-24.04-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.6, ubuntu-24.04) (push) Waiting to run
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, .ci/build-mac.sh, Intel) (push) Waiting to run
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, .ci/build-mac-arm64.sh, Apple Silicon) (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
Build RPCS3 / RPCS3 Windows Clang (win64, clang, clang64) (push) Waiting to run
Build RPCS3 / RPCS3 FreeBSD (push) Waiting to run

This commit is contained in:
Elad 2025-10-22 07:49:35 +03:00
parent f61aaf83f6
commit 2f86f95c3f
5 changed files with 36 additions and 5 deletions

View file

@ -15,7 +15,7 @@ u32 SPUDisAsm::disasm(u32 pc)
{
last_opcode.clear();
if (pc < m_start_pc || pc >= SPU_LS_SIZE)
if (!m_shm || pc < m_start_pc || pc >= SPU_LS_SIZE)
{
return 0;
}

View file

@ -1329,6 +1329,16 @@ namespace vm
std::vector<std::pair<u64, u64>> event_data;
ensure(size == _page_unmap(it->first, size, this->flags, it->second.second.get(), unmapped ? *unmapped : event_data));
if (it->second.second && addr < 0xE0000000)
{
if (it->second.second.use_count() != 1)
{
fmt::throw_exception("External memory usage at block 0x%x (addr=0x%x, size=0x%x)", this->addr, it->first, size);
}
it->second.second.reset();
}
it = next;
}
@ -1338,6 +1348,8 @@ namespace vm
#ifdef _WIN32
m_common->unmap_critical(vm::get_super_ptr(addr));
#endif
ensure(m_common.use_count() == 1);
m_common.reset();
}
return true;
@ -1349,6 +1361,7 @@ namespace vm
block_t::~block_t()
{
ensure(!is_valid());
ensure(!m_common || m_common.use_count() == 1);
}
u32 block_t::alloc(const u32 orig_size, const std::shared_ptr<utils::shm>* src, u32 align, u64 flags)
@ -2244,7 +2257,11 @@ namespace vm
for (auto& block : g_locations)
{
if (block) _unmap_block(block);
if (block)
{
_unmap_block(block);
ensure(block.use_count() == 1);
}
}
g_locations.clear();

View file

@ -241,6 +241,9 @@ void debugger_frame::closeEvent(QCloseEvent* event)
QDockWidget::closeEvent(event);
Q_EMIT DebugFrameClosed();
m_spu_disasm_memory.reset();
m_cpu.reset();
}
void debugger_frame::showEvent(QShowEvent* event)

View file

@ -20,6 +20,7 @@
#include <QWheelEvent>
#include <QHoverEvent>
#include <QMouseEvent>
#include <QCloseEvent>
#include <QTimer>
#include <QThread>
#include <QKeyEvent>
@ -732,7 +733,7 @@ void* memory_viewer_panel::to_ptr(u32 addr, u32 size) const
}
case thread_class::spu:
{
if (size <= SPU_LS_SIZE && SPU_LS_SIZE - size >= (addr % SPU_LS_SIZE))
if (m_spu_shm && size <= SPU_LS_SIZE && SPU_LS_SIZE - size >= (addr % SPU_LS_SIZE))
{
return m_spu_shm->map_self() + (addr % SPU_LS_SIZE);
}
@ -961,6 +962,14 @@ void memory_viewer_panel::keyPressEvent(QKeyEvent* event)
QDialog::keyPressEvent(event);
}
void memory_viewer_panel::closeEvent(QCloseEvent* event)
{
event->accept();
m_spu_shm.reset();
m_disasm.reset();
m_get_cpu = [](){ return std::add_pointer_t<cpu_thread>{}; };
}
void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format format, u32 width, u32 height, bool flipv) const
{
u32 texel_bytes = 4;

View file

@ -19,6 +19,7 @@ class QLabel;
class QThread;
class QHBoxLayout;
class QKeyEvent;
class QCloseEvent;
class cpu_thread;
class CPUDisAsm;
@ -95,10 +96,10 @@ private:
QHBoxLayout* m_hbox_mem_panel = nullptr;
QThread* m_search_thread = nullptr;
const std::function<cpu_thread*()> m_get_cpu;
std::function<cpu_thread*()> m_get_cpu;
const thread_class m_type;
const std::add_pointer_t<rsx::thread> m_rsx;
const std::shared_ptr<utils::shm> m_spu_shm;
std::shared_ptr<utils::shm> m_spu_shm;
const u32 m_addr_mask;
std::shared_ptr<CPUDisAsm> m_disasm;
@ -119,6 +120,7 @@ private:
u64 OnSearch(std::string wstr, u32 mode);
void keyPressEvent(QKeyEvent* event) override;
void closeEvent(QCloseEvent* event) override;
};
// Lifetime management with IDM