summaryrefslogtreecommitdiff
path: root/test/ruby/test_method.rb
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2023-12-24 21:26:37 -0500
committerPeter Zhu <[email protected]>2023-12-24 22:13:49 -0500
commitb4efa4b7005efee484e61fbc6af9c652fee36db2 (patch)
tree5c1556521231d47f2531417a9fc61451c2464bc5 /test/ruby/test_method.rb
parent1b5f3dd6a1a5d054e3fd5af10b5dc2f49e1046fc (diff)
Don't copy RUBY_FL_PROMOTED flag in rb_obj_setup
RUBY_FL_PROMOTED is used by the garbage collector to track when an object becomes promoted to the old generation. rb_obj_setup must not copy that flag over because then it may become out-of-sync with the age of the object. This fixes a bug in Method#clone where the cloned Method object may get RUBY_FL_PROMOTED incorrectly set.
Diffstat (limited to 'test/ruby/test_method.rb')
-rw-r--r--test/ruby/test_method.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 9f34164a77..b22dd9cbee 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -450,6 +450,17 @@ class TestMethod < Test::Unit::TestCase
assert_equal(:bar, m.clone.bar)
end
+ def test_clone_under_gc_compact_stress
+ EnvUtil.under_gc_compact_stress do
+ o = Object.new
+ def o.foo; :foo; end
+ m = o.method(:foo)
+ def m.bar; :bar; end
+ assert_equal(:foo, m.clone.call)
+ assert_equal(:bar, m.clone.bar)
+ end
+ end
+
def test_inspect
o = Object.new
def o.foo; end; line_no = __LINE__