summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2021-02-11 15:32:19 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2021-02-12 11:23:57 -0800
commit15dbaa0b54f10e43976d594ef987da5f51e0c7c1 (patch)
tree5245cebe339bd6837d388c2a84890749478157b2 /vm.c
parent1f0e0dfb228fd14b3f6687539ba274ba6a2d1643 (diff)
[Fixes #17622] Mark and move the previous ep
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4175
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 2899433..ef1bf0f 100644
--- a/vm.c
+++ b/vm.c
@@ -2806,6 +2806,11 @@ rb_execution_context_update(const rb_execution_context_t *ec)
cfp->block_code = (void *)rb_gc_location((VALUE)cfp->block_code);
if (!VM_ENV_LOCAL_P(ep)) {
+ const VALUE *prev_ep = VM_ENV_PREV_EP(ep);
+ if (VM_ENV_FLAGS(prev_ep, VM_ENV_FLAG_ESCAPED)) {
+ VM_FORCE_WRITE(&prev_ep[VM_ENV_DATA_INDEX_ENV], rb_gc_location(prev_ep[VM_ENV_DATA_INDEX_ENV]));
+ }
+
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]));
@@ -2846,6 +2851,11 @@ rb_execution_context_mark(const rb_execution_context_t *ec)
rb_gc_mark_movable((VALUE)cfp->block_code);
if (!VM_ENV_LOCAL_P(ep)) {
+ const VALUE *prev_ep = VM_ENV_PREV_EP(ep);
+ if (VM_ENV_FLAGS(prev_ep, VM_ENV_FLAG_ESCAPED)) {
+ rb_gc_mark_movable(prev_ep[VM_ENV_DATA_INDEX_ENV]);
+ }
+
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]);