From a0ecdbfbfe57a57ab33bdb5e1de4d5dfa8407dbb Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 15 Oct 2024 16:57:09 -0700 Subject: [PATCH] Remove "simple" flag from forwarded ICs I don't think we should ever consider forwarded IC's to be "simple". Previously, the "simple" flag would be copied to the derived IC and this happened to cause struct set / get iseqs to write an invalid CC fastpath: https://github.com/tenderlove/ruby/blob/f45eb3dcb9c7d849064cb802953f37e1cf9f3996/vm_insnhelper.c#L4726-L4729 [Bug #20799] --- bootstraptest/test_method.rb | 21 +++++++++++++++++++++ vm_args.c | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb index af9443b8c6..f6f04541d6 100644 --- a/bootstraptest/test_method.rb +++ b/bootstraptest/test_method.rb @@ -1374,3 +1374,24 @@ assert_equal 'ok', %q{ foo(:foo, b: :ok) foo(*["foo"], b: :ok) } + +assert_equal 'ok', %q{ + Thing = Struct.new(:value) + + Obj = Thing.new("ok") + + def delegate(...) + Obj.value(...) + end + + def no_args + delegate + end + + def splat_args(*args) + delegate(*args) + end + + no_args + splat_args +} diff --git a/vm_args.c b/vm_args.c index 0ecdc31a31..28f685d7dd 100644 --- a/vm_args.c +++ b/vm_args.c @@ -1177,7 +1177,7 @@ vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *r *adjusted_ci = VM_CI_ON_STACK( site_mid, - (caller_flag | (site_flag & (VM_CALL_FCALL | VM_CALL_FORWARDING))), + ((caller_flag & ~VM_CALL_ARGS_SIMPLE) | (site_flag & (VM_CALL_FCALL | VM_CALL_FORWARDING))), site_argc + caller_argc, kw );