Project

General

Profile

Actions

Bug #19464

closed

YJIT miscompiles `BasicObject#__send__` to alias methods of `send`

Added by alanwu (Alan Wu) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:112583]

Description

Symptoms first experienced and reported by users of the kt-paperclip gem.
Reproducer:

klass = Class.new do
  class << self
    alias_method :my_send, :send

    def bar = :ok

    def foo = bar
  end
end

with_break = -> { break klass.send(:my_send, :foo) }
wo_break = -> { klass.send(:my_send, :foo) }

31.times { with_break[]; wo_break[] }

Fix: https://github.com/ruby/ruby/pull/7377

Actions #1

Updated by alanwu (Alan Wu) over 1 year ago

  • Description updated (diff)
Actions #2

Updated by alanwu (Alan Wu) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|0eb634ae73cb327ede833b72492f912792a4a9d5.


YJIT: Detect and reject send(:alias_for_send, :foo)

Previously, YJIT failed to put the stack into the correct shape when
BasicObject#send calls an alias method for the send method itself.
This can manifest as strange NoMethodErrors in the final non-send
receiver, as seen with the kt-paperclip gem. I also found a case
where it makes YJIT fail the stack size assertion while compiling
leave.

YJIT's BasicObject#__send__ implementation already rejects sends to
send, but didn't detect sends to aliases of send. Adjust the
detection and reject these cases.

Fixes [Bug #19464]

Actions #3

Updated by alanwu (Alan Wu) over 1 year ago

  • Subject changed from YJIT miscompiles `BasicObject#send` to alias methods of `send` to YJIT miscompiles `BasicObject#__send__` to alias methods of `send`

Updated by naruse (Yui NARUSE) over 1 year ago

  • Backport changed from 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE

ruby_3_2 b73a07359758a9034996752e981e09ddaffe8d87 merged revision(s) 0eb634ae73cb327ede833b72492f912792a4a9d5.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0