From 8fd6f8f6e975b9e455d2824410b4a2231e949474 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 1 May 2019 17:32:45 +0200 Subject: [PATCH] Call Host_NotifyMapLoaded when clearing g_symbolDB Otherwise DolphinQt will have a stale symbol list and you can get nullptr dereferences when trying to use it. --- Source/Core/Common/SymbolDB.cpp | 5 +++++ Source/Core/Common/SymbolDB.h | 1 + Source/Core/Core/Boot/Boot.cpp | 6 +++++- Source/Core/Core/ConfigManager.cpp | 7 ++++++- Source/Core/Core/IOS/MIOS.cpp | 8 +++++++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/SymbolDB.cpp b/Source/Core/Common/SymbolDB.cpp index b433671daa..c24faaa8c9 100644 --- a/Source/Core/Common/SymbolDB.cpp +++ b/Source/Core/Common/SymbolDB.cpp @@ -42,6 +42,11 @@ void SymbolDB::List() INFO_LOG(OSHLE, "%zu functions known in this program above.", m_functions.size()); } +bool SymbolDB::IsEmpty() const +{ + return m_functions.empty(); +} + void SymbolDB::Clear(const char* prefix) { // TODO: honor prefix diff --git a/Source/Core/Common/SymbolDB.h b/Source/Core/Common/SymbolDB.h index 22486ec057..8d389b5a92 100644 --- a/Source/Core/Common/SymbolDB.h +++ b/Source/Core/Common/SymbolDB.h @@ -78,6 +78,7 @@ public: const XFuncMap& Symbols() const { return m_functions; } XFuncMap& AccessSymbols() { return m_functions; } + bool IsEmpty() const; void Clear(const char* prefix = ""); void List(); void Index(); diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index f34468d2f9..5da27aac5f 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -383,7 +383,11 @@ bool CBoot::BootUp(std::unique_ptr boot) { SConfig& config = SConfig::GetInstance(); - g_symbolDB.Clear(); + if (!g_symbolDB.IsEmpty()) + { + g_symbolDB.Clear(); + UpdateDebugger_MapLoaded(); + } // PAL Wii uses NTSC framerate and linecount in 60Hz modes VideoInterface::Preset(DiscIO::IsNTSC(config.m_region) || diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 8b48886c57..235955ab5c 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -35,6 +35,7 @@ #include "Core/HLE/HLE.h" #include "Core/HW/DVD/DVDInterface.h" #include "Core/HW/SI/SI.h" +#include "Core/Host.h" #include "Core/IOS/ES/ES.h" #include "Core/IOS/ES/Formats.h" #include "Core/PatchEngine.h" @@ -724,7 +725,11 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri if (Core::IsRunning()) { // TODO: have a callback mechanism for title changes? - g_symbolDB.Clear(); + if (!g_symbolDB.IsEmpty()) + { + g_symbolDB.Clear(); + Host_NotifyMapLoaded(); + } CBoot::LoadMapFromFilename(); HLE::Reload(); PatchEngine::Reload(); diff --git a/Source/Core/Core/IOS/MIOS.cpp b/Source/Core/Core/IOS/MIOS.cpp index bbee3284fe..c94c2ee957 100644 --- a/Source/Core/Core/IOS/MIOS.cpp +++ b/Source/Core/Core/IOS/MIOS.cpp @@ -20,6 +20,7 @@ #include "Core/HW/DVD/DVDInterface.h" #include "Core/HW/Memmap.h" #include "Core/HW/SystemTimers.h" +#include "Core/Host.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" @@ -52,11 +53,16 @@ bool Load() NOTICE_LOG(IOS, "Reinitialised hardware."); // Load symbols for the IPL if they exist. - g_symbolDB.Clear(); + if (!g_symbolDB.IsEmpty()) + { + g_symbolDB.Clear(); + Host_NotifyMapLoaded(); + } if (g_symbolDB.LoadMap(File::GetUserPath(D_MAPS_IDX) + "mios-ipl.map")) { ::HLE::Clear(); ::HLE::PatchFunctions(); + Host_NotifyMapLoaded(); } const PowerPC::CoreMode core_mode = PowerPC::GetMode();