diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-08-18 14:09:29 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-08-18 17:23:19 +0900 |
commit | 574f3af36ea008896419d2e2407f8fce83bdcd2e (patch) | |
tree | 9df37ef765bfeddf40ae25adc85e375eeeec4e79 /signal.c | |
parent | 58bd9434360d5a46974eaa03139893c0145615dc (diff) |
Rewind execution tags more at stack overflow [Bug #18084]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4751
Diffstat (limited to 'signal.c')
-rw-r--r-- | signal.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -878,12 +878,13 @@ check_stack_overflow(int sig, const uintptr_t addr, const ucontext_t *ctx) (sp_page <= fault_page && fault_page <= bp_page)) { rb_execution_context_t *ec = GET_EC(); int crit = FALSE; - if ((uintptr_t)ec->tag->buf / pagesize <= fault_page + 1) { + int uplevel = roomof(pagesize, sizeof(*ec->tag)) / 2; /* XXX: heuristic */ + while ((uintptr_t)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. */ + if ((crit = (!ec->tag->prev || !--uplevel)) != FALSE) break; ec->tag = ec->tag->prev; - crit = TRUE; } reset_sigmask(sig); rb_ec_stack_overflow(ec, crit); |