From 08e26836f1116fba4ef1b674f2f9b37e0e4ebb03 Mon Sep 17 00:00:00 2001 From: Michael Käppler Date: Sat, 7 Sep 2024 22:52:22 +0200 Subject: Fix setjmp/longjmp-related crashes on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * libguile/Makefile.am: add new header file setjump-win.h * libguile/continuations.h, libguile/dynstack.c, libguile/dynstack.h, libguile/intrinsics.h, libguile/vm.h: supply custom `setjmp` macro on Windows Mingw implements `setjmp (env)` as a macro that expands to _setjmp (env, faddr) where `faddr` is set to the current frame address. This address is then stored as first element in the jump buffer `env`. When `longjmp` is called, it tries to unwind the stack up to the saved address by calling `RtlUnwindEx` from MSVCRT, which will fail, if the stack frames are interwoven with JIT-generated code, that violate the Windows x64 calling conventions. Thus implement the macro ourselves as _setjmp (env, NULL) which will toggle a code path in `longjmp` that does no unwinding. Signed-off-by: Ludovic Courtès --- libguile/dynstack.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libguile/dynstack.c') diff --git a/libguile/dynstack.c b/libguile/dynstack.c index 2eec7a7eb..e4ed878c2 100644 --- a/libguile/dynstack.c +++ b/libguile/dynstack.c @@ -25,7 +25,12 @@ #endif #include + +#ifndef _WIN64 #include +#else +#include "setjump-win.h" +#endif #include "control.h" #include "eval.h" -- cgit v1.2.3