Skip to content
  • eileencodes's avatar
    8a3d5797
    Fix cvar caching when class is cloned · 8a3d5797
    eileencodes authored
    The class variable cache that was added in
    https://github.com/ruby/ruby/pull/4544
    
     changed the behavior of class
    variables on cloned classes. As reported when a class is cloned AND a
    class variable was set, and the class variable was read from the
    original class, reading a class variable from the cloned class would
    return the value from the original class.
    
    This was happening because the IC (inline cache) is stored on the ISEQ
    which is shared between the original and cloned class, therefore they
    share the cache too.
    
    To fix this we are now storing the `cref` in the cache so that we can
    check if it's equal to the current `cref`. If it's different we don't
    want to read from the cache. If it's the same we do. Cloned classes
    don't share the same cref with their original class.
    
    This will need to be backported to 3.1 in addition to 3.2 since the bug
    exists in both versions.
    
    We also added a marking function which was missing.
    
    Fixes [Bug #19379]
    
    Co-authored-by: default avatarAaron Patterson <tenderlove@ruby-lang.org>
    8a3d5797
    Fix cvar caching when class is cloned
    eileencodes authored
    The class variable cache that was added in
    https://github.com/ruby/ruby/pull/4544
    
     changed the behavior of class
    variables on cloned classes. As reported when a class is cloned AND a
    class variable was set, and the class variable was read from the
    original class, reading a class variable from the cloned class would
    return the value from the original class.
    
    This was happening because the IC (inline cache) is stored on the ISEQ
    which is shared between the original and cloned class, therefore they
    share the cache too.
    
    To fix this we are now storing the `cref` in the cache so that we can
    check if it's equal to the current `cref`. If it's different we don't
    want to read from the cache. If it's the same we do. Cloned classes
    don't share the same cref with their original class.
    
    This will need to be backported to 3.1 in addition to 3.2 since the bug
    exists in both versions.
    
    We also added a marking function which was missing.
    
    Fixes [Bug #19379]
    
    Co-authored-by: default avatarAaron Patterson <tenderlove@ruby-lang.org>
Loading