Project

General

Profile

Actions

Bug #20285

closed

Stale inline method caches when refinement modules are reopened

Bug #20285: Stale inline method caches when refinement modules are reopened

Added by jhawthorn (John Hawthorn) over 1 year ago. Updated over 1 year ago.


Description

This is essentially the same issue as #11672, but for inline method caches rather than class caches.

In Ruby 3.3 we started using inline caches for refinements. However, we weren't clearing inline caches when defined on a reopened refinement module.

class C
end

module R
  refine C do
    def m
      :foo
    end
  end
end

using R
def m
  C.new.m
end

raise unless :foo == m()

module R
  refine C do
    alias m m
    def m
      :bar
    end
  end
end

v = m()
raise "expected :bar, got #{v.inspect}" unless :bar == v

This will raise in Ruby 3.3 as the inline cache finds a stale refinement, but passes in previous versions.


Related issues 2 (0 open2 closed)

Related to Ruby - Bug #11672: refinement Closedko1 (Koichi Sasada)Actions
Is duplicate of Ruby - Bug #20246: Unexpected behavior for Regexp in Subexpression Calls on Ruby 3.3.0ClosedActions

Updated by jhawthorn (John Hawthorn) over 1 year ago Actions #1 [ruby-core:116889]

  • Backport changed from 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: UNKNOWN to 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED

Fixed by https://github.com/ruby/ruby/pull/10037

I'll mark this as requiring a backport for 3.3, but I think there's probably minimal impact from this issue.

Updated by jhawthorn (John Hawthorn) over 1 year ago Actions #2

Updated by jhawthorn (John Hawthorn) over 1 year ago Actions #3

  • Subject changed from Stale inline method caches when refinement modules are reloaded to Stale inline method caches when refinement modules are reopened

Updated by k0kubun (Takashi Kokubun) over 1 year ago Actions #4

  • Status changed from Assigned to Closed

Updated by k0kubun (Takashi Kokubun) over 1 year ago Actions #5 [ruby-core:118060]

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

05787897f69087abdabee926971cdf364bd73730 seems to have backported this to ruby_3_3.

Updated by k0kubun (Takashi Kokubun) over 1 year ago Actions #6

  • Is duplicate of Bug #20246: Unexpected behavior for Regexp in Subexpression Calls on Ruby 3.3.0 added
Actions

Also available in: PDF Atom