PPU LLVM: Fix leak of modules outside dev_flash/sys/internal

Cache path was not matching on removal
This commit is contained in:
Eladash 2024-03-30 20:25:03 +03:00 committed by Elad Ashkenazi
parent 7c8be662c6
commit e90b399329

View file

@ -3594,6 +3594,15 @@ namespace
if (found == bucket.map.end()) [[unlikely]] if (found == bucket.map.end()) [[unlikely]]
{ {
ppu_log.error("Failed to remove module %s", name); ppu_log.error("Failed to remove module %s", name);
for (auto& buck : buckets)
{
for (auto& mod : buck.map)
{
ppu_log.notice("But there is module %s", mod.first);
}
}
return; return;
} }
@ -3721,21 +3730,26 @@ extern void ppu_finalize(const ppu_module& info, bool force_mem_release)
const bool may_be_elf = fmt::to_lower(info.path.substr(std::max<usz>(info.path.size(), 3) - 3)) != "prx"; const bool may_be_elf = fmt::to_lower(info.path.substr(std::max<usz>(info.path.size(), 3) - 3)) != "prx";
const std::string dev_flash = vfs::get("/dev_flash/");
if (!may_be_elf) if (!may_be_elf)
{ {
const std::string dev_flash = vfs::get("/dev_flash/sys/external"); if (!force_mem_release && info.path.starts_with(dev_flash + "sys/external/"))
if (!force_mem_release && info.path.starts_with(dev_flash))
{ {
// Don't remove dev_flash prx from memory // Don't remove dev_flash prx from memory
return; return;
} }
} }
if (g_cfg.core.ppu_decoder != ppu_decoder_type::llvm)
{
return;
}
// Get cache path for this executable // Get cache path for this executable
std::string cache_path = fs::get_cache_dir() + "cache/"; std::string cache_path = fs::get_cache_dir() + "cache/";
if (!Emu.GetTitleID().empty()) if (!info.path.starts_with(dev_flash) && !Emu.GetTitleID().empty() && Emu.GetCat() != "1P")
{ {
cache_path += Emu.GetTitleID(); cache_path += Emu.GetTitleID();
cache_path += '/'; cache_path += '/';
@ -4366,7 +4380,7 @@ extern void ppu_initialize()
} }
} }
const std::string firmware_sprx_path = vfs::get(dev_flash_located ? "/dev_flash/"sv : "/dev_flash/sys/"sv); const std::string firmware_sprx_path = vfs::get(dev_flash_located ? "/dev_flash/"sv : "/dev_flash/sys/external/"sv);
dir_queue.emplace_back(firmware_sprx_path); dir_queue.emplace_back(firmware_sprx_path);
} }