ruby-changes:33866
From: nobu <ko1@a...>
Date: Thu, 15 May 2014 17:33:08 +0900 (JST)
Subject: [ruby-changes:33866] nobu:r45947 (trunk): Handle machine stack overflow on mingw
nobu 2014-05-15 17:32:55 +0900 (Thu, 15 May 2014) New Revision: 45947 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45947 Log: Handle machine stack overflow on mingw * 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. Modified files: trunk/ChangeLog trunk/eval_intern.h trunk/thread_win32.c Index: eval_intern.h =================================================================== --- eval_intern.h (revision 45946) +++ eval_intern.h (revision 45947) @@ -95,6 +95,15 @@ extern int select_large_fdset(int, fd_se https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L95 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 Index: thread_win32.c =================================================================== --- thread_win32.c (revision 45946) +++ thread_win32.c (revision 45947) @@ -754,6 +754,18 @@ ruby_stack_overflowed_p(const rb_thread_ https://github.com/ruby/ruby/blob/trunk/thread_win32.c#L754 return rb_thread_raised_p(th, RAISED_STACKOVERFLOW); } +#if defined(__MINGW32__) +LONG WINAPI +rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *exception) +{ + if (exception->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) { + rb_thread_raised_set(GET_THREAD(), RAISED_STACKOVERFLOW); + raise(SIGSEGV); + } + return EXCEPTION_CONTINUE_SEARCH; +} +#endif + #ifdef RUBY_ALLOCA_CHKSTK void ruby_alloca_chkstk(size_t len, void *sp) Index: ChangeLog =================================================================== --- ChangeLog (revision 45946) +++ ChangeLog (revision 45947) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu May 15 17:32:51 2014 Hiroshi Shirosaki <h.shirosaki@g...> + + * 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. + Wed May 14 19:31:03 2014 Koichi Sasada <ko1@a...> * ext/openssl/depend: remove dependency from internal headers. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/