From 19199564d3ac69b8bbe18a272c1d5177f8d1aaa9 Mon Sep 17 00:00:00 2001 From: butilly Date: Sat, 7 Nov 2026 07:20:32 +0000 Subject: [PATCH] WOW64: guard exception handling before FEX thread initialization --- Source/Windows/WOW64/Module.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Windows/WOW64/Module.cpp b/Source/Windows/WOW64/Module.cpp index 8c6b7f76e1..0841aae81f 100644 --- a/Source/Windows/WOW64/Module.cpp +++ b/Source/Windows/WOW64/Module.cpp @@ -729,6 +729,14 @@ bool BTCpuResetToConsistentStateImpl(EXCEPTION_POINTERS* Ptrs) { auto* Context = Ptrs->ContextRecord; auto* Exception = Ptrs->ExceptionRecord; auto Thread = GetTLS().ThreadState(); + // Exceptions can arrive during process/thread initialization, before the FEX + // thread is published in TLS. Profiling and the JIT handlers dereference it, + // so let Wine dispatch these faults instead of recursively faulting here. + // Overcommit faults are process-wide and can still be handled at this stage. + if (!Thread) { + return Exception->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && OvercommitTracker && + OvercommitTracker->HandleAccessViolation(static_cast(Exception->ExceptionInformation[1])); + } FEXCORE_PROFILE_ACCUMULATION(Thread, AccumulatedSignalTime); if (Exception->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { @@ -769,7 +777,7 @@ bool BTCpuResetToConsistentStateImpl(EXCEPTION_POINTERS* Ptrs) { } } - if (!Thread || !IsAddressInJit(Context->Pc)) { + if (!IsAddressInJit(Context->Pc)) { return false; }