Release breakpoint lock before the AV/GUARD_PAGE handler callback (fixes deadlock when the handler pauses and the main thread reads memory)

This commit is contained in:
linsmod 2026-08-03 08:54:04 +08:00
parent ccac889f27
commit 8176594910
1 changed files with 8 additions and 0 deletions

View File

@ -1193,6 +1193,14 @@ __declspec(dllexport) void TITCALL DebugLoop()
// Debuggee generated the GUARD_PAGE or ACCESS_VIOLATION exception // Debuggee generated the GUARD_PAGE or ACCESS_VIOLATION exception
if(DBGCode == DBG_EXCEPTION_NOT_HANDLED) 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(isAccessViolation)
{ {
if(DBGCustomHandler->chAccessViolation != NULL) if(DBGCustomHandler->chAccessViolation != NULL)