From 96dc6fad2d611b953dca0e2e6f478fb25b9412ce Mon Sep 17 00:00:00 2001 From: Christian Haeubl Date: Mon, 21 Jul 2025 12:36:55 +0200 Subject: [PATCH] Use SetUnhandledExceptionFilter on Windows. --- .../svm/core/windows/WindowsSubstrateSegfaultHandler.java | 2 ++ .../com/oracle/svm/core/windows/headers/ErrHandlingAPI.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSubstrateSegfaultHandler.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSubstrateSegfaultHandler.java index cd4026e23620..3113f88adc0b 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSubstrateSegfaultHandler.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSubstrateSegfaultHandler.java @@ -73,6 +73,8 @@ public void install() { if (ErrHandlingAPI.AddVectoredContinueHandler(0, HANDLER_LITERAL.getFunctionPointer()).isNull()) { VMError.shouldNotReachHere("SubstrateSegfaultHandler installation failed."); } + /* Install secondary signal handler. */ + ErrHandlingAPI.SetUnhandledExceptionFilter(HANDLER_LITERAL.getFunctionPointer()); } private static final CEntryPointLiteral HANDLER_LITERAL = CEntryPointLiteral.create(WindowsSubstrateSegfaultHandler.class, "handler", ErrHandlingAPI.EXCEPTION_POINTERS.class); diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/ErrHandlingAPI.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/ErrHandlingAPI.java index 2f819ac8123b..9391cce3c544 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/ErrHandlingAPI.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/headers/ErrHandlingAPI.java @@ -51,6 +51,9 @@ public class ErrHandlingAPI { @CFunction(transition = NO_TRANSITION) public static native PointerBase AddVectoredContinueHandler(int first, CFunctionPointer handler); + @CFunction(transition = NO_TRANSITION) + public static native CFunctionPointer SetUnhandledExceptionFilter(CFunctionPointer handler); + @CConstant public static native int EXCEPTION_CONTINUE_SEARCH();