From 8fa9c07c9a33174905e67589bea6be3e278712cb Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 29 Jul 2015 20:13:23 +0200 Subject: [PATCH] Fix sigsetjmp for w64 Latest mingw-w64 for Debian obviously gets the include files (and thus the declaration of sigsetjmp) in the wrong order. This results in executables which try to unwind the stack when longjmp is called from generated code. They fail to do so and crash. Signed-off-by: Stefan Weil --- cpu-exec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpu-exec.c b/cpu-exec.c index bb40edbb1a..830bf4255b 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -29,6 +29,14 @@ #include "qemu/rcu.h" #include "exec/tb-hash.h" +#if defined(_WIN64) +/* On w64, sigsetjmp is implemented by _setjmp which needs a second parameter. + * If this parameter is NULL, longjump does no stack unwinding. + * That is what we need for QEMU. Passing the value of register rsp (default) + * lets longjmp try a stack unwinding which will crash with generated code. */ +#define sigsetjmp(env, savesigs) _setjmp(env, NULL) +#endif + /* -icount align implementation. */ typedef struct SyncClocks { -- 2.11.4.GIT