From 9df086f59181f8b9deb35f671231dd2273a25f42 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 20 May 2020 13:44:09 -0700 Subject: [PATCH] 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. --- gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 0c007dffe6..dfc3212a58 100644 --- a/gc.c +++ b/gc.c @@ -7568,7 +7568,7 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj) return FALSE; } } - return !RVALUE_PINNED(obj); + return RVALUE_MARKED(obj) && !RVALUE_PINNED(obj); break; default: -- 2.26.2