lock vm around rb_free_generic_ivar
Currently, this can be reproduced by: r = Ractor.new do a = [1, 2, 3] a.object_id a.dup # this frees the generic ivar for `object_id` on the copied object :done end r.take In debug builds, this hits an assertion failure without this fix.
This commit is contained in:
parent
627a5ac53b
commit
966fcb77e4
Notes:
git
2025-05-23 09:20:48 +00:00
@ -2319,6 +2319,16 @@ assert_equal 'ok', %q{
|
|||||||
'ok'
|
'ok'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# take vm lock when deleting generic ivars from the global table
|
||||||
|
assert_equal 'ok', %q{
|
||||||
|
Ractor.new do
|
||||||
|
a = [1, 2, 3]
|
||||||
|
a.object_id
|
||||||
|
a.dup # this deletes generic ivar on dupped object
|
||||||
|
'ok'
|
||||||
|
end.take
|
||||||
|
}
|
||||||
|
|
||||||
# There are some bugs in Windows with multiple threads in same ractor calling ractor actions
|
# There are some bugs in Windows with multiple threads in same ractor calling ractor actions
|
||||||
# Ex: https://github.com/ruby/ruby/actions/runs/14998660285/job/42139383905
|
# Ex: https://github.com/ruby/ruby/actions/runs/14998660285/job/42139383905
|
||||||
unless /mswin/ =~ RUBY_PLATFORM
|
unless /mswin/ =~ RUBY_PLATFORM
|
||||||
|
16
variable.c
16
variable.c
@ -1273,15 +1273,19 @@ rb_free_generic_ivar(VALUE obj)
|
|||||||
|
|
||||||
bool too_complex = rb_shape_obj_too_complex_p(obj);
|
bool too_complex = rb_shape_obj_too_complex_p(obj);
|
||||||
|
|
||||||
if (st_delete(generic_fields_tbl_no_ractor_check(obj), &key, &value)) {
|
RB_VM_LOCK_ENTER();
|
||||||
struct gen_fields_tbl *fields_tbl = (struct gen_fields_tbl *)value;
|
{
|
||||||
|
if (st_delete(generic_fields_tbl_no_ractor_check(obj), &key, &value)) {
|
||||||
|
struct gen_fields_tbl *fields_tbl = (struct gen_fields_tbl *)value;
|
||||||
|
|
||||||
if (UNLIKELY(too_complex)) {
|
if (UNLIKELY(too_complex)) {
|
||||||
st_free_table(fields_tbl->as.complex.table);
|
st_free_table(fields_tbl->as.complex.table);
|
||||||
|
}
|
||||||
|
|
||||||
|
xfree(fields_tbl);
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(fields_tbl);
|
|
||||||
}
|
}
|
||||||
|
RB_VM_LOCK_LEAVE();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
Loading…
x
Reference in New Issue
Block a user