summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_ractor.rb13
-rw-r--r--ractor.c6
2 files changed, 19 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index 7e77dfcec1..80591f6459 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -1405,4 +1405,17 @@ assert_equal "ok", %q{
end
}
+assert_equal "ok", %q{
+ GC.disable
+ Ractor.new {}
+ raise "not ok" unless GC.disable
+
+ foo = []
+ 10.times { foo << 1 }
+
+ GC.start
+
+ 'ok'
+}
+
end # if !ENV['GITHUB_WORKFLOW']
diff --git a/ractor.c b/ractor.c
index 372305c256..b5835a8ca6 100644
--- a/ractor.c
+++ b/ractor.c
@@ -1420,9 +1420,15 @@ cancel_single_ractor_mode(void)
// enable multi-ractor mode
RUBY_DEBUG_LOG("enable multi-ractor mode", 0);
+ VALUE was_disabled = rb_gc_enable();
+
rb_gc_start();
rb_transient_heap_evacuate();
+ if (was_disabled) {
+ rb_gc_disable();
+ }
+
ruby_single_main_ractor = NULL;
if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL)) {