ruby-changes:47518
From: nobu <ko1@a...>
Date: Tue, 22 Aug 2017 11:46:21 +0900 (JST)
Subject: [ruby-changes:47518] nobu:r59634 (trunk): signal.c: fatal stack
nobu 2017-08-22 11:46:16 +0900 (Tue, 22 Aug 2017) New Revision: 59634 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59634 Log: signal.c: fatal stack * signal.c (check_stack_overflow): raise fatal when the last tag is in danger zone. Modified files: trunk/signal.c trunk/vm_eval.c trunk/vm_insnhelper.c Index: vm_eval.c =================================================================== --- vm_eval.c (revision 59633) +++ vm_eval.c (revision 59634) @@ -258,7 +258,7 @@ stack_check(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L258 if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) && rb_threadptr_stack_check(th)) { rb_thread_raised_set(th, RAISED_STACKOVERFLOW); - rb_threadptr_stack_overflow(th); + rb_threadptr_stack_overflow(th, FALSE); } } Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 59633) +++ vm_insnhelper.c (revision 59634) @@ -52,11 +52,11 @@ vm_stackoverflow(void) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L52 threadptr_stack_overflow(GET_THREAD(), TRUE); } -NORETURN(void rb_threadptr_stack_overflow(rb_thread_t *th)); +NORETURN(void rb_threadptr_stack_overflow(rb_thread_t *th, int crit)); void -rb_threadptr_stack_overflow(rb_thread_t *th) +rb_threadptr_stack_overflow(rb_thread_t *th, int crit) { - if (rb_during_gc()) { + if (crit || rb_during_gc()) { th->ec.raised_flag = RAISED_STACKOVERFLOW; th->ec.errinfo = th->vm->special_exceptions[ruby_error_stackfatal]; TH_JUMP_TAG(th, TAG_RAISE); Index: signal.c =================================================================== --- signal.c (revision 59633) +++ signal.c (revision 59634) @@ -763,7 +763,7 @@ static const char *received_signal; https://github.com/ruby/ruby/blob/trunk/signal.c#L763 #endif #if defined(USE_SIGALTSTACK) || defined(_WIN32) -NORETURN(void rb_threadptr_stack_overflow(rb_thread_t *th)); +NORETURN(void rb_threadptr_stack_overflow(rb_thread_t *th, int crit)); # if defined __HAIKU__ # define USE_UCONTEXT_REG 1 # elif !(defined(HAVE_UCONTEXT_H) && (defined __i386__ || defined __x86_64__ || defined __amd64__)) @@ -843,14 +843,16 @@ check_stack_overflow(int sig, const uint https://github.com/ruby/ruby/blob/trunk/signal.c#L843 if (sp_page == fault_page || sp_page == fault_page + 1 || sp_page <= fault_page && fault_page <= bp_page) { rb_thread_t *th = ruby_current_thread; + int crit = FALSE; if ((uintptr_t)th->ec.tag->buf / pagesize <= fault_page + 1) { /* drop the last tag if it is close to the fault, * otherwise it can cause stack overflow again at the same * place. */ th->ec.tag = th->ec.tag->prev; + crit = TRUE; } reset_sigmask(sig); - rb_threadptr_stack_overflow(th); + rb_threadptr_stack_overflow(th, crit); } } # else @@ -861,7 +863,7 @@ check_stack_overflow(int sig, const void https://github.com/ruby/ruby/blob/trunk/signal.c#L863 rb_thread_t *th = ruby_current_thread; if (ruby_stack_overflowed_p(th, addr)) { reset_sigmask(sig); - rb_threadptr_stack_overflow(th); + rb_threadptr_stack_overflow(th, FALSE); } } # endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/