summaryrefslogtreecommitdiff
path: root/nt/inc
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2015-08-08 11:12:06 +0300
committerEli Zaretskii <eliz@gnu.org>2015-08-08 11:12:06 +0300
commit7afa4f300b9dc38bf3f33b18fa83bfe35e21a479 (patch)
tree032ab5a75ec1ff00cee51ffe6216fceb16a53e6c /nt/inc
parent35656b6fa473a4c422875a61d24ebb736c1be4e9 (diff)
downloademacs-7afa4f300b9dc38bf3f33b18fa83bfe35e21a479.tar.gz
Support recovery from C stack overflow on MS-Windows
* src/w32fns.c (w32_reset_stack_overflow_guard) (stack_overflow_handler): New functions for handling C stack overflow exceptions. (my_exception_handler): Handle EXCEPTION_STACK_OVERFLOW exceptions specially, and zero out except_addr if we do. (globals_of_w32fns): Initialize dwMainThreadId in non-interactive mode. * src/sysdep.c [HAVE_STACK_OVERFLOW_HANDLING]: Add !WINDOWSNT to the condition, as HAVE_STACK_OVERFLOW_HANDLING is now defined for the MinGW build, but the code guarded by that is for Posix hosts. * src/keyboard.c (command_loop) [WINDOWSNT]: Call w32_reset_stack_overflow_guard. * nt/inc/ms-w32.h (sigjmp_buf): New typedef. (sigsetjmp): New macro. (w32_reset_stack_overflow_guard): Declare the prototype. * configure.ac (HAVE_STACK_OVERFLOW_HANDLING): Set to 1 for MinGW.
Diffstat (limited to 'nt/inc')
-rw-r--r--nt/inc/ms-w32.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index 4fb32df0c07..e7a94e81c2d 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -187,6 +187,20 @@ extern struct tm * sys_localtime (const time_t *);
#undef HAVE__SETJMP
#endif
+/* The following is needed for recovery from C stack overflows. */
+#include <setjmp.h>
+typedef jmp_buf sigjmp_buf;
+#ifdef MINGW_W64
+/* Evidently, MinGW64's longjmp crashes when invoked from an exception
+ handler, see https://sourceforge.net/p/mingw-w64/mailman/message/32421953/.
+ This seems to be an unsolved problem in the MinGW64 runtime. So we
+ use the GCC intrinsics instead. FIXME. */
+#define sigsetjmp(j,m) __builtin_setjmp(j)
+#else
+#define sigsetjmp(j,m) setjmp(j)
+#endif
+extern void w32_reset_stack_overflow_guard (void);
+
#ifdef _MSC_VER
#include <sys/timeb.h>
#include <sys/stat.h>