Skip to content

Commit

Permalink
Fixed heap-use-after-free on racter
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Sep 4, 2020
1 parent fbaab56 commit d164eef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gc.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions ractor.c
Expand Up @@ -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)
{
Expand Down

0 comments on commit d164eef

Please sign in to comment.