ruby-changes:73989
From: Jemma <ko1@a...>
Date: Sat, 15 Oct 2022 04:00:03 +0900 (JST)
Subject: [ruby-changes:73989] 9a5684bf7f (master): Add test for ractor race condition on ivar sets
https://git.ruby-lang.org/ruby.git/commit/?id=9a5684bf7f From 9a5684bf7f92ae71a55ede82ec18c31c161694ec Mon Sep 17 00:00:00 2001 From: Jemma Issroff <jemmaissroff@g...> Date: Tue, 4 Oct 2022 15:27:13 -0400 Subject: Add test for ractor race condition on ivar sets --- bootstraptest/test_ractor.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index b29db7ab0e..6373349e42 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -1579,4 +1579,43 @@ assert_equal "ok", %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_ractor.rb#L1579 end } +assert_equal "ok", %q{ + module M + def foo + @foo + end + end + + class A + include M + + def initialize + 100.times { |i| instance_variable_set(:"@var_#{i}", "bad: #{i}") } + @foo = 2 + end + end + + class B + include M + + def initialize + @foo = 1 + end + end + + Ractor.new do + b = B.new + 100_000.times do + raise unless b.foo == 1 + end + end + + a = A.new + 100_000.times do + raise unless a.foo == 2 + end + + "ok" +} + end # if !ENV['GITHUB_WORKFLOW'] -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/