summaryrefslogtreecommitdiff
path: root/eval_intern.h
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-27 08:03:11 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-27 08:03:11 +0000
commit2c1a9c3db35785087bba6624d7df5130be8ab97e (patch)
tree02fe76641324d80466b9570ac6e2a6157e83ccfb /eval_intern.h
parent2fcf1bb6736ae0c34239abc43d01826924988de7 (diff)
merge revision(s) 43748,45947,45951: [Backport #9739]
* eval_intern.h (SAVE_ROOT_JMPBUF): workaround for the failure of test/ruby/test_exception.rb on Windows. wrap by __try and __exception statements on mswin to raise SIGSEGV when EXCEPTION_STACK_OVERFLOW is occurred, because MSVCRT doesn't handle the exception. however, (1) mingw-gcc doesn't support __try and __exception statements, and (2) we cannot retry SystemStackError after this change yet (maybe crashed) because SEH and longjmp() are too uncongenial. * signal.c (check_stack_overflow, CHECK_STACK_OVERFLOW): now defined on Windows, too. * thread_win32.c (ruby_stack_overflowed_p): ditto. * thread_win32.c (rb_w32_stack_overflow_handler): use Structured Exception Handling by Addvectoredexceptionhandler() for machine stack overflow on mingw. This would be equivalent to the handling using __try and __exept on mswin introduced by r43748. Exception Handling by AddVectoredExceptionHandler() for machine This would be equivalent to the handling using __try and __except git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_intern.h')
-rw-r--r--eval_intern.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/eval_intern.h b/eval_intern.h
index 334b8d439a..a47480a953 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -83,9 +83,37 @@ extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval
#include <sys/stat.h>
+#ifdef _MSC_VER
+#define SAVE_ROOT_JMPBUF_BEFORE_STMT \
+ __try {
+#define SAVE_ROOT_JMPBUF_AFTER_STMT \
+ } \
+ __except (GetExceptionCode() == EXCEPTION_STACK_OVERFLOW ? \
+ (rb_thread_raised_set(GET_THREAD(), RAISED_STACKOVERFLOW), \
+ raise(SIGSEGV), \
+ EXCEPTION_EXECUTE_HANDLER) : \
+ EXCEPTION_CONTINUE_SEARCH) { \
+ /* never reaches here */ \
+ }
+#elif defined(__MINGW32__)
+LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
+#define SAVE_ROOT_JMPBUF_BEFORE_STMT \
+ do { \
+ PVOID _handler = AddVectoredExceptionHandler(1, rb_w32_stack_overflow_handler);
+
+#define SAVE_ROOT_JMPBUF_AFTER_STMT \
+ RemoveVectoredExceptionHandler(_handler); \
+ } while (0);
+#else
+#define SAVE_ROOT_JMPBUF_BEFORE_STMT
+#define SAVE_ROOT_JMPBUF_AFTER_STMT
+#endif
+
#define SAVE_ROOT_JMPBUF(th, stmt) do \
if (ruby_setjmp((th)->root_jmpbuf) == 0) { \
+ SAVE_ROOT_JMPBUF_BEFORE_STMT \
stmt; \
+ SAVE_ROOT_JMPBUF_AFTER_STMT \
} \
else { \
rb_fiber_start(); \