From adc0bf933e1232b43e01e79c8c676ba9420ab5ad Mon Sep 17 00:00:00 2001 From: ko1 Date: Mon, 8 Jan 2018 15:27:56 +0000 Subject: [PATCH] fix mark miss of Env (which is pointed by prev_ep). * vm.c (rb_execution_context_mark): r61624 and r61659 introduce marking miss bug for Env objects as a prev_ep which is contained by Proc objects because Proc objects can be collected when they should be living and Env objects will collected unexpectedly. This patch solves this problem. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vm.c b/vm.c index ae002c4721..60647605a6 100644 --- a/vm.c +++ b/vm.c @@ -2354,14 +2354,21 @@ rb_execution_context_mark(const rb_execution_context_t *ec) rb_gc_mark_values((long)(sp - p), p); while (cfp != limit_cfp) { -#if VM_CHECK_MODE > 0 const VALUE *ep = cfp->ep; +#if VM_CHECK_MODE > 0 VM_ASSERT(!!VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED) == vm_ep_in_heap_p_(ec, ep)); #endif rb_gc_mark(cfp->self); rb_gc_mark((VALUE)cfp->iseq); rb_gc_mark((VALUE)cfp->block_code); + if (!VM_ENV_LOCAL_P(ep)) { + const VALUE *prev_ep = VM_ENV_PREV_EP(ep); + if (VM_ENV_ESCAPED_P(prev_ep)) { + rb_gc_mark(prev_ep[VM_ENV_DATA_INDEX_ENV]); + } + } + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } }