ruby-changes:65284
From: Koichi <ko1@a...>
Date: Thu, 18 Feb 2021 17:04:37 +0900 (JST)
Subject: [ruby-changes:65284] 100e464bee (master): clear RVALUE on NEWOBJ event.
https://git.ruby-lang.org/ruby.git/commit/?id=100e464bee From 100e464bee46ae71ef048ed85a9bdd012935a3f7 Mon Sep 17 00:00:00 2001 From: Koichi Sasada <ko1@a...> Date: Thu, 18 Feb 2021 16:15:41 +0900 Subject: clear RVALUE on NEWOBJ event. NEWOBJ event is called without clearing RVALUE values (v1, v2, v3). This patch clear them before NEWOBJ tracepoint internal hook. [Bug #17599] --- gc.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/gc.c b/gc.c index 33d4632..b5d4339 100644 --- a/gc.c +++ b/gc.c @@ -2073,12 +2073,15 @@ gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb https://github.com/ruby/ruby/blob/trunk/gc.c#L2073 #define gc_event_hook_available_p(objspace) ((objspace)->flags.has_hook) #define gc_event_hook_needed_p(objspace, event) ((objspace)->hook_events & (event)) -#define gc_event_hook(objspace, event, data) do { \ +#define gc_event_hook_prep(objspace, event, data, prep) do { \ if (UNLIKELY(gc_event_hook_needed_p(objspace, event))) { \ + prep; \ gc_event_hook_body(GET_EC(), (objspace), (event), (data)); \ } \ } while (0) +#define gc_event_hook(objspace, event, data) gc_event_hook_prep(objspace, event, data, (void)0) + static inline VALUE newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace, VALUE obj) { @@ -2224,6 +2227,16 @@ ractor_cache_slots(rb_objspace_t *objspace, rb_ractor_t *cr) https://github.com/ruby/ruby/blob/trunk/gc.c#L2227 asan_poison_object((VALUE)cr->newobj_cache.freelist); } +static inline VALUE +newobj_fill(VALUE obj, VALUE v1, VALUE v2, VALUE v3) +{ + RVALUE *p = (RVALUE *)obj; + p->as.values.v1 = v1; + p->as.values.v2 = v2; + p->as.values.v3 = v3; + return obj; +} + ALWAYS_INLINE(static VALUE newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t *cr, int wb_protected)); static inline VALUE @@ -2254,7 +2267,7 @@ newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t * https://github.com/ruby/ruby/blob/trunk/gc.c#L2267 } GC_ASSERT(obj != 0); newobj_init(klass, flags, wb_protected, objspace, obj); - gc_event_hook(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj); + gc_event_hook_prep(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj, newobj_fill(obj, 0, 0, 0)); } RB_VM_LOCK_LEAVE_CR_LEV(cr, &lev); @@ -2316,16 +2329,6 @@ newobj_of0(VALUE klass, VALUE flags, int wb_protected, rb_ractor_t *cr) https://github.com/ruby/ruby/blob/trunk/gc.c#L2329 } static inline VALUE -newobj_fill(VALUE obj, VALUE v1, VALUE v2, VALUE v3) -{ - RVALUE *p = (RVALUE *)obj; - p->as.values.v1 = v1; - p->as.values.v2 = v2; - p->as.values.v3 = v3; - return obj; -} - -static inline VALUE newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected) { VALUE obj = newobj_of0(klass, flags, wb_protected, GET_RACTOR()); -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/