[前][次][番号順一覧][スレッド一覧]

ruby-changes:67182

From: Nobuyoshi <ko1@a...>
Date: Wed, 18 Aug 2021 18:18:48 +0900 (JST)
Subject: [ruby-changes:67182] 574f3af36e (master): Rewind execution tags more at stack overflow [Bug #18084]

https://git.ruby-lang.org/ruby.git/commit/?id=574f3af36e

From 574f3af36ea008896419d2e2407f8fce83bdcd2e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 18 Aug 2021 14:09:29 +0900
Subject: Rewind execution tags more at stack overflow [Bug #18084]

---
 signal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/signal.c b/signal.c
index 46ac6c2..dd05e82 100644
--- a/signal.c
+++ b/signal.c
@@ -878,12 +878,13 @@ check_stack_overflow(int sig, const uintptr_t addr, const ucontext_t *ctx) https://github.com/ruby/ruby/blob/trunk/signal.c#L878
         (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);
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]