Skip to content

Commit

Permalink
Rewind execution tags more at stack overflow [Bug #18084]
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Aug 18, 2021
1 parent 58bd943 commit 574f3af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions signal.c
Expand Up @@ -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);
Expand Down

0 comments on commit 574f3af

Please sign in to comment.