summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-22 02:46:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-22 02:46:16 +0000
commit066e9a8b4ac36907f8e7915b5f94fdc7ca851de0 (patch)
treeab4755a81c14142791da4fd3bbe15413b1ee31c0 /signal.c
parent2f3eef8ee06492817804536210ff6d74e0d467c4 (diff)
signal.c: fatal stack
* signal.c (check_stack_overflow): raise fatal when the last tag is in danger zone. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/signal.c b/signal.c
index 5674b832ef..113bfe7d24 100644
--- a/signal.c
+++ b/signal.c
@@ -763,7 +763,7 @@ static const char *received_signal;
#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 uintptr_t addr, const ucontext_t *ctx)
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 *addr)
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