1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fixed heap-use-after-free on racter

This commit is contained in:
Nobuyoshi Nakada 2020-09-04 15:17:42 +09:00
parent fbaab562d9
commit d164eef957
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 11 additions and 0 deletions

3
gc.c
View file

@ -3597,6 +3597,8 @@ force_chain_object(st_data_t key, st_data_t val, st_data_t arg)
return ST_CONTINUE;
}
bool rb_obj_is_main_ractor(VALUE gv);
void
rb_objspace_call_finalizer(rb_objspace_t *objspace)
{
@ -3652,6 +3654,7 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
if (rb_obj_is_thread(vp)) break;
if (rb_obj_is_mutex(vp)) break;
if (rb_obj_is_fiber(vp)) break;
if (rb_obj_is_main_ractor(vp)) break;
if (RTYPEDDATA_P(vp)) {
RDATA(p)->dfree = RANY(p)->as.typeddata.type->function.dfree;
}

View file

@ -1434,6 +1434,14 @@ rb_ractor_main_p_(void)
return rb_ec_ractor_ptr(ec) == rb_ec_vm_ptr(ec)->ractor.main_ractor;
}
bool
rb_obj_is_main_ractor(VALUE gv)
{
if (!rb_ractor_p(gv)) return false;
rb_ractor_t *r = DATA_PTR(gv);
return r == GET_VM()->ractor.main_ractor;
}
rb_global_vm_lock_t *
rb_ractor_gvl(rb_ractor_t *r)
{