ruby-changes:62827
From: Nobuyoshi <ko1@a...>
Date: Fri, 4 Sep 2020 15:22:51 +0900 (JST)
Subject: [ruby-changes:62827] d164eef957 (master): Fixed heap-use-after-free on racter
https://git.ruby-lang.org/ruby.git/commit/?id=d164eef957 From d164eef9577175e51bc17c1da75a9092d86030a9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 4 Sep 2020 15:17:42 +0900 Subject: Fixed heap-use-after-free on racter diff --git a/gc.c b/gc.c index 99c79fe..69cc2ba 100644 --- a/gc.c +++ b/gc.c @@ -3597,6 +3597,8 @@ force_chain_object(st_data_t key, st_data_t val, st_data_t arg) https://github.com/ruby/ruby/blob/trunk/gc.c#L3597 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) https://github.com/ruby/ruby/blob/trunk/gc.c#L3654 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; } diff --git a/ractor.c b/ractor.c index 9a8146e..5ea0257 100644 --- a/ractor.c +++ b/ractor.c @@ -1434,6 +1434,14 @@ rb_ractor_main_p_(void) https://github.com/ruby/ruby/blob/trunk/ractor.c#L1434 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) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/