summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2025-11-26 14:02:17 -0800
committerJohn Hawthorn <john@hawthorn.email>2025-11-26 16:13:38 -0800
commit5bef7577b3b336a709935dd39e69abcf397c4684 (patch)
tree72dd8d38a41989c9615dbc205dd0892b11d6a212 /test/ruby
parent970b18e9a94ff3e6496fb7324cff0798ffec6f24 (diff)
Ensure we don't dereference fields_obj as Qundef
We rely on the GC to clear this when the GC is run on another EC than the cache.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_variable.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb
index d4ba0f9fc7..13b8a7905f 100644
--- a/test/ruby/test_variable.rb
+++ b/test/ruby/test_variable.rb
@@ -529,6 +529,22 @@ class TestVariable < Test::Unit::TestCase
assert_equal :new_value, str.instance_variable_get(:@x)
end
+ def test_genivar_cache_invalidated_by_gc
+ str = +"hello"
+ str.instance_variable_set(:@x, :old_value)
+
+ str.instance_variable_get(:@x) # populate cache
+
+ Fiber.new {
+ str.remove_instance_variable(:@x)
+ str.instance_variable_set(:@x, :new_value)
+ }.resume
+
+ GC.start
+
+ assert_equal :new_value, str.instance_variable_get(:@x)
+ end
+
private
def with_kwargs_11(v1:, v2:, v3:, v4:, v5:, v6:, v7:, v8:, v9:, v10:, v11:)
local_variables