diff options
author | Michael Käppler <xmichael-k@web.de> | 2024-09-07 22:52:22 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2024-10-20 12:14:21 +0200 |
commit | 08e26836f1116fba4ef1b674f2f9b37e0e4ebb03 (patch) | |
tree | 48385f78061d1a3854a097427088b41639dc029c /libguile/vm.h | |
parent | c0bfa3219cb9a0b9f5a0185caa1d8c5b5cd33fd2 (diff) | |
download | guile-08e26836f1116fba4ef1b674f2f9b37e0e4ebb03.tar.gz |
Fix setjmp/longjmp-related crashes on Windows
* 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 <ludo@gnu.org>
Diffstat (limited to 'libguile/vm.h')
-rw-r--r-- | libguile/vm.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libguile/vm.h b/libguile/vm.h index 9681188bd..d5b7138d3 100644 --- a/libguile/vm.h +++ b/libguile/vm.h @@ -20,7 +20,11 @@ #ifndef _SCM_VM_H_ #define _SCM_VM_H_ +#ifndef _WIN64 #include <setjmp.h> +#else +#include "libguile/setjump-win.h" +#endif #include <libguile/gc.h> #include <libguile/programs.h> |