summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2021-12-24 12:26:21 +0900
committerKoichi Sasada <ko1@atdot.net>2021-12-24 13:52:02 +0900
commit6050e3e2a6ce2269c56fa74bc5b75a94d064b61f (patch)
tree2547646ab7a59516ddc0f40a6bded331904dfcd7 /bootstraptest
parente029560b22fef5dd665495a2af01c11ffcd33e12 (diff)
@@cv is not accessible from non-main ractors
Class variables (@@cv) is not accessible from non-main ractors. But without this patch cached @@cv can be read. fix [Bug #18128]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5335
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_ractor.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index 5d9edb26d6..b29db7ab0e 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -1101,6 +1101,28 @@ assert_equal 'can not access class variables from non-main Ractors', %q{
end
}
+# also cached cvar in shareable-objects are not allowed to access from non-main Ractor
+assert_equal 'can not access class variables from non-main Ractors', %q{
+ class C
+ @@cv = 'str'
+ def self.cv
+ @@cv
+ end
+ end
+
+ C.cv # cache
+
+ r = Ractor.new do
+ C.cv
+ end
+
+ begin
+ r.take
+ rescue Ractor::RemoteError => e
+ e.cause.message
+ end
+}
+
# Getting non-shareable objects via constants by other Ractors is not allowed
assert_equal 'can not access non-shareable objects in constant C::CONST by non-main Ractor.', %q{
class C