mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
a3e79c1764
commit
6e7e7c1e57
1 changed files with 1 additions and 1 deletions
2
gc.c
2
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));
|
||||
|
|
Loading…
Add table
Reference in a new issue