ruby-changes:68941
From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:24 +0900 (JST)
Subject: [ruby-changes:68941] 546ca8167d (master): Guard for T_OBJECT at compile time (#53)
https://git.ruby-lang.org/ruby.git/commit/?id=546ca8167d From 546ca8167d341bca2b7a1927950a0369b5185bf0 Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Wed, 26 May 2021 13:09:32 -0700 Subject: Guard for T_OBJECT at compile time (#53) Previously this could crash on Nokogiri when JITing the getivar instruction because we would attempt to treat Nokogiri::XML::Document's T_DATA as a T_OBJECT in calling rb_iv_index_tbl_lookup. This commit also checks for T_OBJECT at compile time and emits the rb_ivar_get fallback in that case. Co-authored-by: HParker <HParker@g...> Co-authored-by: Dinah Shi <dinahshi@g...> Co-authored-by: HParker <HParker@g...> Co-authored-by: Dinah Shi <dinahshi@g...> --- yjit_codegen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yjit_codegen.c b/yjit_codegen.c index c2bdd96e86..8a8a9aa565 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -1014,7 +1014,8 @@ gen_get_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1014 // NOTE: This assumes nobody changes the allocator of the class after allocation. // Eventually, we can encode whether an object is T_OBJECT or not // inside object shapes. - if (rb_get_alloc_func(comptime_val_klass) != rb_class_allocate_instance) { + if (!RB_TYPE_P(comptime_receiver, T_OBJECT) || + rb_get_alloc_func(comptime_val_klass) != rb_class_allocate_instance) { // General case. Call rb_ivar_get(). No need to reconstruct interpreter // state since the routine never raises exceptions or allocate objects // visibile to Ruby. -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/