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

ruby-changes:63804

From: Aaron <ko1@a...>
Date: Tue, 1 Dec 2020 07:45:52 +0900 (JST)
Subject: [ruby-changes:63804] 56bb6e7d58 (master): Only check if the current ep is a local or not, then mark

https://git.ruby-lang.org/ruby.git/commit/?id=56bb6e7d58

From 56bb6e7d582f2e73c23f05594cd89d6deea9c318 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Mon, 30 Nov 2020 13:28:24 -0800
Subject: Only check if the current ep is a local or not, then mark

The vm mark function should only check if the current frame is a local
or not and then mark values in that frame.  Since it's walking up the
stack looking at each cfp, then all ep's should be examined.

This fixes a bug in the Rails tests where we're seeing segv in railties.

Thanks Yasuo Honda for giving me a reliable repro!

diff --git a/vm.c b/vm.c
index e105a41..9114ba4 100644
--- a/vm.c
+++ b/vm.c
@@ -2782,12 +2782,11 @@ rb_execution_context_update(const rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/vm.c#L2782
             cfp->iseq = (rb_iseq_t *)rb_gc_location((VALUE)cfp->iseq);
             cfp->block_code = (void *)rb_gc_location((VALUE)cfp->block_code);
 
-            while (!VM_ENV_LOCAL_P(ep)) {
+            if (!VM_ENV_LOCAL_P(ep)) {
                 if (VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED)) {
                     VM_FORCE_WRITE(&ep[VM_ENV_DATA_INDEX_ENV], rb_gc_location(ep[VM_ENV_DATA_INDEX_ENV]));
                     VM_FORCE_WRITE(&ep[VM_ENV_DATA_INDEX_ME_CREF], rb_gc_location(ep[VM_ENV_DATA_INDEX_ME_CREF]));
                 }
-                ep = VM_ENV_PREV_EP(ep);
             }
 
             cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
@@ -2823,12 +2822,11 @@ rb_execution_context_mark(const rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/vm.c#L2822
             rb_gc_mark_movable((VALUE)cfp->iseq);
             rb_gc_mark_movable((VALUE)cfp->block_code);
 
-            while (!VM_ENV_LOCAL_P(ep)) {
+            if (!VM_ENV_LOCAL_P(ep)) {
 		if (VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED)) {
                     rb_gc_mark_movable(ep[VM_ENV_DATA_INDEX_ENV]);
                     rb_gc_mark(ep[VM_ENV_DATA_INDEX_ME_CREF]);
 		}
-                ep = VM_ENV_PREV_EP(ep);
             }
 
 	    cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
-- 
cgit v0.10.2


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

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