mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Ivar copy needs to happen _before_ setting the shape
When we copy instance variables, it is possible for the GC to be kicked off. The GC looks at the shape to determine what slots to mark inside the object. If the shape is set too soon, the GC could think that there are more instance variables on the object than there actually are at that moment.
This commit is contained in:
parent
0d1e1987d1
commit
70173a72a2
2 changed files with 6 additions and 6 deletions
|
@ -19,8 +19,8 @@ class RbBaseCommand:
|
||||||
|
|
||||||
imemo_types = target.FindFirstType("enum imemo_type")
|
imemo_types = target.FindFirstType("enum imemo_type")
|
||||||
|
|
||||||
for member in imemo_types.GetEnumMembers():
|
#for member in imemo_types.GetEnumMembers():
|
||||||
g[member.GetName()] = member.GetValueAsUnsigned()
|
# g[member.GetName()] = member.GetValueAsUnsigned()
|
||||||
|
|
||||||
for enum in target.FindFirstGlobalVariable("ruby_dummy_gdb_enums"):
|
for enum in target.FindFirstGlobalVariable("ruby_dummy_gdb_enums"):
|
||||||
enum = enum.GetType()
|
enum = enum.GetType()
|
||||||
|
|
8
object.c
8
object.c
|
@ -298,6 +298,10 @@ init_copy(VALUE dest, VALUE obj)
|
||||||
rb_copy_generic_ivar(dest, obj);
|
rb_copy_generic_ivar(dest, obj);
|
||||||
rb_gc_copy_finalizer(dest, obj);
|
rb_gc_copy_finalizer(dest, obj);
|
||||||
|
|
||||||
|
if (RB_TYPE_P(obj, T_OBJECT)) {
|
||||||
|
rb_obj_copy_ivar(dest, obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (!RB_TYPE_P(obj, T_CLASS) && !RB_TYPE_P(obj, T_MODULE)) {
|
if (!RB_TYPE_P(obj, T_CLASS) && !RB_TYPE_P(obj, T_MODULE)) {
|
||||||
rb_shape_t *shape_to_set = rb_shape_get_shape(obj);
|
rb_shape_t *shape_to_set = rb_shape_get_shape(obj);
|
||||||
|
|
||||||
|
@ -310,10 +314,6 @@ init_copy(VALUE dest, VALUE obj)
|
||||||
// shape ids are different
|
// shape ids are different
|
||||||
rb_shape_set_shape(dest, shape_to_set);
|
rb_shape_set_shape(dest, shape_to_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RB_TYPE_P(obj, T_OBJECT)) {
|
|
||||||
rb_obj_copy_ivar(dest, obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE immutable_obj_clone(VALUE obj, VALUE kwfreeze);
|
static VALUE immutable_obj_clone(VALUE obj, VALUE kwfreeze);
|
||||||
|
|
Loading…
Reference in a new issue