From 972c8a97dc33245ce76ff8f9e0c7970e5ab3f71e Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Tue, 12 Aug 2025 00:23:52 +0100 Subject: [PATCH] ARM64EC: Disable syscall callbacks when handling OvercommitTracker AVs We don't need to be informed of our own mappings, avoids a deadlock that occurs if the ThreadCreationMutex lifetime is extended when creating a thread. --- Source/Windows/ARM64EC/Module.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Windows/ARM64EC/Module.cpp b/Source/Windows/ARM64EC/Module.cpp index 026ba821b..ff502a0d1 100644 --- a/Source/Windows/ARM64EC/Module.cpp +++ b/Source/Windows/ARM64EC/Module.cpp @@ -768,11 +768,18 @@ bool ResetToConsistentStateImpl(EXCEPTION_RECORD* Exception, CONTEXT* GuestConte } NTSTATUS ResetToConsistentState(EXCEPTION_RECORD* Exception, CONTEXT* GuestContext, ARM64_NT_CONTEXT* NativeContext) { + bool Cont {}; if (Exception->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { const auto FaultAddress = static_cast(Exception->ExceptionInformation[1]); - if (OvercommitTracker && OvercommitTracker->HandleAccessViolation(FaultAddress)) { - NtContinueNative(NativeContext, false); + if (OvercommitTracker) { + { + ScopedCallbackDisable guard; + Cont = OvercommitTracker->HandleAccessViolation(FaultAddress); + } + if (Cont) { + NtContinueNative(NativeContext, false); + } } } @@ -780,7 +787,6 @@ NTSTATUS ResetToConsistentState(EXCEPTION_RECORD* Exception, CONTEXT* GuestConte return STATUS_SUCCESS; } - bool Cont {}; { ScopedCallbackDisable guard;