summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2020-05-20 13:44:09 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2020-05-20 15:00:32 -0700
commit6e7e7c1e577d6c2276e9a8cc85c28c55c46c2618 (patch)
treee4c96c738384970d45c074f7f57bf366d96375a2
parenta3e79c1764c268f7a6e0b443a2818120c077f700 (diff)
Only marked objects should be considered movable
Ruby's GC is incremental, meaning that during the mark phase (and also the sweep phase) programs are allowed to run. This means that programs can allocate objects before the mark or sweep phase have actually completed. Those objects may not have had a chance to be marked, so we can't know if they are movable or not. Something that references the newly created object might have called the pinning function during the mark phase, but since the mark phase hasn't run we can't know if there is a "pinning" relationship. To be conservative, we must only allow objects that are not pinned but also marked to move.
-rw-r--r--gc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 6353a7b50a..b0fa670e9e 100644
--- a/gc.c
+++ b/gc.c
@@ -7599,7 +7599,7 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
return FALSE;
}
}
- return !RVALUE_PINNED(obj);
+ return RVALUE_MARKED(obj) && !RVALUE_PINNED(obj);
default:
rb_bug("gc_is_moveable_obj: unreachable (%d)", (int)BUILTIN_TYPE(obj));