From 6050e3e2a6ce2269c56fa74bc5b75a94d064b61f Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 24 Dec 2021 12:26:21 +0900 Subject: @@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] --- bootstraptest/test_ractor.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'bootstraptest') 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 -- cgit v1.2.3