diff --git a/Core/System.cpp b/Core/System.cpp index 054aba96fe..3e1e452ca5 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -568,6 +568,12 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin } void CPU_Shutdown(bool success) { + // Held across the whole teardown, not just Memory::Shutdown() further down. Everything below + // frees state the debugger UIs read from other threads - kernel objects, the symbol map, the + // memory map - and this is the lock they take to be sure none of it goes away mid-read. See + // Memory::Lock(); it's recursive, so the nested acquire in Memory::Shutdown() is fine. + Memory::MemoryInitedLock coreLock = Memory::Lock(); + UninstallExceptionHandler(); GPURecord::Replay_Unload();