From 81765949103924c40679ad3ed54432f73aad37a9 Mon Sep 17 00:00:00 2001 From: linsmod Date: Mon, 3 Aug 2026 08:54:04 +0800 Subject: [PATCH] Release breakpoint lock before the AV/GUARD_PAGE handler callback (fixes deadlock when the handler pauses and the main thread reads memory) --- TitanEngine/TitanEngine.Debugger.DebugLoop.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TitanEngine/TitanEngine.Debugger.DebugLoop.cpp b/TitanEngine/TitanEngine.Debugger.DebugLoop.cpp index 9f92bd0..7f3a7a7 100644 --- a/TitanEngine/TitanEngine.Debugger.DebugLoop.cpp +++ b/TitanEngine/TitanEngine.Debugger.DebugLoop.cpp @@ -1193,6 +1193,14 @@ __declspec(dllexport) void TITCALL DebugLoop() // Debuggee generated the GUARD_PAGE or ACCESS_VIOLATION exception if(DBGCode == DBG_EXCEPTION_NOT_HANDLED) { + // The AV/GUARD_PAGE handler may block until the debugger resumes + // the target (debuggers pause on the second-chance exception). + // It is called from inside the memory-breakpoint transaction lock + // above, so release it first or any MemoryReadSafe the debugger + // runs while paused (BreakPointPostReadFilter takes this same + // lock) deadlocks on memory inspection after a crash stop. + breakpointLock.unlock(); + if(isAccessViolation) { if(DBGCustomHandler->chAccessViolation != NULL)