summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorLuke Gruber <luke.gruber@shopify.com>2025-12-18 12:37:27 -0500
committerGitHub <noreply@github.com>2025-12-18 12:37:27 -0500
commitbfd28d581c524c7a7df877f2425de9fdd8de161a (patch)
treeed9d77592680e0d2f5b1a28e273282cb6fb06296 /test/ruby
parentf133ebb2db664801f87efa98aa91d610d194b700 (diff)
make rb_singleton_class ractor safe (#15591)
Since singleton classes are created lazily, we need to make sure that we lock around their creation. Unfortunately, that means we need to lock around every shareable object's call to `singleton_class`, including classes and modules.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_class.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index 22078514ad..8f12e06685 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -930,4 +930,19 @@ CODE
end.each(&:join)
end;
end
+
+ def test_safe_multi_ractor_singleton_class_access
+ assert_ractor "#{<<~"begin;"}\n#{<<~'end;'}"
+ begin;
+ class A; end
+ 4.times.map do
+ Ractor.new do
+ a = A
+ 100.times do
+ a = a.singleton_class
+ end
+ end
+ end.each(&:join)
+ end;
+ end
end