summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-09-05 14:12:20 +0900
committernagachika <nagachika@ruby-lang.org>2021-09-05 14:12:20 +0900
commit3fb51aec5ba7decffdfc32e540262aaae6167a95 (patch)
tree2b7db8f9f92cbf740393113360e1c19016508f41 /bootstraptest
parent911e75f0547ae3496280a731fbfd986096b0ffb6 (diff)
merge revision(s) bbedd29b6e98ef6e3fc2ce2b358d2b509b7cd1bb: [Backport #18117]
[Bug #18117] Fix Ractor race condition with GC rb_objspace_reachable_objects_from requires that the GC not be active. Since the Ractor barrier is not executed for incremental sweeping, Ractor may call rb_objspace_reachable_objects_from after sweeping has started to share objects. This causes a crash that looks like the following: ``` <internal:ractor>:627: [BUG] rb_objspace_reachable_objects_from() is not supported while during_gc == true ``` Co-authored-by: Vinicius Stock <vinicius.stock@shopify.com> --- bootstraptest/test_ractor.rb | 15 +++++++++++++++ ractor.c | 12 ++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_ractor.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index cbf58383c7..f733877319 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -1379,4 +1379,19 @@ assert_equal "ok", %q{
end
}
+# Can yield back values while GC is sweeping [Bug #18117]
+assert_equal "ok", %q{
+ workers = (0...8).map do
+ Ractor.new do
+ loop do
+ 10_000.times.map { Object.new }
+ Ractor.yield Time.now
+ end
+ end
+ end
+
+ 1_000.times { idle_worker, tmp_reporter = Ractor.select(*workers) }
+ "ok"
+}
+
end # if !ENV['GITHUB_WORKFLOW']