Evacuate transient heap when enabling ractors
If the GC has been disabled we need to re-enable it so we can evacuate the transient heap. Fixes https://bugs.ruby-lang.org/issues/17985 [Bug #17985] [ruby-core:104260] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
This commit is contained in:
parent
2fb435b3ab
commit
8209b73580
Notes:
git
2021-06-24 02:03:37 +09:00
@ -1405,4 +1405,17 @@ assert_equal "ok", %q{
|
|||||||
end
|
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']
|
end # if !ENV['GITHUB_WORKFLOW']
|
||||||
|
6
ractor.c
6
ractor.c
@ -1420,9 +1420,15 @@ cancel_single_ractor_mode(void)
|
|||||||
// enable multi-ractor mode
|
// enable multi-ractor mode
|
||||||
RUBY_DEBUG_LOG("enable multi-ractor mode", 0);
|
RUBY_DEBUG_LOG("enable multi-ractor mode", 0);
|
||||||
|
|
||||||
|
VALUE was_disabled = rb_gc_enable();
|
||||||
|
|
||||||
rb_gc_start();
|
rb_gc_start();
|
||||||
rb_transient_heap_evacuate();
|
rb_transient_heap_evacuate();
|
||||||
|
|
||||||
|
if (was_disabled) {
|
||||||
|
rb_gc_disable();
|
||||||
|
}
|
||||||
|
|
||||||
ruby_single_main_ractor = NULL;
|
ruby_single_main_ractor = NULL;
|
||||||
|
|
||||||
if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL)) {
|
if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user