Skip to content

Commit 447eced

Browse files
authored
Merge pull request #32 from ruby/sync-ruby-core
Sync from ruby/ruby
2 parents 7deef0f + b8edf3a commit 447eced

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

gc/mmtk/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ default = []
3535

3636
# When moving an object, clear its original copy.
3737
clear_old_copy = []
38+
39+
[workspace]

gc/mmtk/mmtk.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,11 @@ rb_gc_impl_undefine_finalizer(void *objspace_ptr, VALUE obj)
966966
struct objspace *objspace = objspace_ptr;
967967

968968
st_data_t data = obj;
969+
970+
int lev = rb_gc_vm_lock();
969971
st_delete(objspace->finalizer_table, &data, 0);
972+
rb_gc_vm_unlock(lev);
973+
970974
FL_UNSET(obj, FL_FINALIZE);
971975
}
972976

@@ -979,14 +983,17 @@ rb_gc_impl_copy_finalizer(void *objspace_ptr, VALUE dest, VALUE obj)
979983

980984
if (!FL_TEST(obj, FL_FINALIZE)) return;
981985

986+
int lev = rb_gc_vm_lock();
982987
if (RB_LIKELY(st_lookup(objspace->finalizer_table, obj, &data))) {
983-
table = (VALUE)data;
988+
table = rb_ary_dup((VALUE)data);
989+
RARRAY_ASET(table, 0, rb_obj_id(dest));
984990
st_insert(objspace->finalizer_table, dest, table);
985991
FL_SET(dest, FL_FINALIZE);
986992
}
987993
else {
988994
rb_bug("rb_gc_copy_finalizer: FL_FINALIZE set but not found in finalizer_table: %s", rb_obj_info(obj));
989995
}
996+
rb_gc_vm_unlock(lev);
990997
}
991998

992999
static int

0 commit comments

Comments
 (0)