1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Rewind execution tags more at stack overflow [Bug #18084]

This commit is contained in:
Nobuyoshi Nakada 2021-08-18 14:09:29 +09:00
parent 58bd943436
commit 574f3af36e
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
Notes: git 2021-08-18 18:18:53 +09:00

View file

@ -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);