Rename Memory::Lock() to Core_LockAgainstShutdown(), move it to Core

It stopped being about memory when CPU_Shutdown started holding it across the
whole teardown - it's what keeps kernel objects, the symbol map and the memory
map from being freed while another thread reads them. The old name invited the
reading that it locks memory *access*, which it has never done.

Memory::Reinit() now holds it across both halves rather than relying on
Memory::Shutdown()'s own acquire: between Shutdown() and Init() there is no
memory map at all, and a reader could slip into that gap.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-08-17 13:11:16 +02:00
1 parent f57a102027
commit 75ff0d406c
16 files changed
+76 -66

No files matched your search

+2 -2
View File
@@ -571,8 +571,8 @@ 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();
// Core_LockAgainstShutdown(); it's recursive, so the nested acquire in Memory::Shutdown() is fine.
CoreShutdownLock coreLock = Core_LockAgainstShutdown();
UninstallExceptionHandler();