ruby/ext/objspace
eileencodes 8a3d57971c Fix cvar caching when class is cloned
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: Aaron Patterson <tenderlove@ruby-lang.org>
2023-07-01 14:17:30 +09:00
..
lib [DOC] Fix format in ObjectSpace.dump_all 2022-12-12 10:16:38 -05:00
depend Fix cvar caching when class is cloned 2023-07-01 14:17:30 +09:00
extconf.rb ext/objspace: Specify frozen_string_literal: true. 2017-02-12 04:31:25 +00:00
object_tracing.c Expand tabs [ci skip] 2022-07-21 09:42:04 -07:00
objspace.c Move error from top_stmts and top_stmt to stmt 2022-10-08 17:59:11 +09:00
objspace.h * ext/objspace/object_tracing.c: Add experimental methods to dump 2013-11-08 17:06:55 +00:00
objspace_dump.c Indicate if a shape is too_complex in ObjectSpace#dump 2022-12-15 13:41:47 -08:00