summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-10 13:27:08 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-10 18:27:44 +0900
commit72f1c43584df714a011864ca9fafc6e15ace392c (patch)
tree250ed361e404e63467530a225e9e6acee5fa4232 /bootstraptest
parent7856da5fe75a76bec909778e411270c10a04ca3a (diff)
ObjectSpace._id2ref should not support unshareable
ObjectSpace._id2ref(id) can return any objects even if they are unshareable, so this patch raises RangeError if it runs on multi-ractor mode and the found object is unshareable.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3878
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_ractor.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index 125b51bf4f..2bbf823f37 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -919,6 +919,19 @@ assert_equal '0', %q{
}.take
}
+# ObjectSpace._id2ref can not handle unshareable objects with Ractors
+assert_equal 'ok', %q{
+ s = 'hello'
+
+ Ractor.new s.object_id do |id ;s|
+ begin
+ s = ObjectSpace._id2ref(id)
+ rescue => e
+ :ok
+ end
+ end.take
+}
+
# Ractor.make_shareable(obj)
assert_equal 'true', %q{
class C