rb_gc_impl_define_finalizer: unlock on early return

This commit is contained in:
Jean Boussier 2025-04-23 07:04:09 +02:00
parent 6029781984
commit 6d0dd7d863
4 changed files with 16 additions and 0 deletions

View File

@ -2847,6 +2847,7 @@ rb_gc_impl_define_finalizer(void *objspace_ptr, VALUE obj, VALUE block)
for (i = 0; i < len; i++) {
VALUE recv = RARRAY_AREF(table, i);
if (rb_equal(recv, block)) {
rb_gc_vm_unlock(lev);
return recv;
}
}

View File

@ -986,6 +986,7 @@ rb_gc_impl_define_finalizer(void *objspace_ptr, VALUE obj, VALUE block)
for (i = 0; i < len; i++) {
VALUE recv = RARRAY_AREF(table, i);
if (rb_equal(recv, block)) {
rb_gc_vm_unlock(lev);
return recv;
}
}

2
test2.rb Normal file
View File

@ -0,0 +1,2 @@
ObjectSpace._id2ref(8) rescue nil

12
test3.rb Normal file
View File

@ -0,0 +1,12 @@
ractors = 5.times.map do |i|
Ractor.new do
100_000.times.map do
o = Object.new
ObjectSpace.define_finalizer(o, ->(id) {})
o
end
end
end
ractors.each(&:take)