ruby-changes:55505
From: Nobuyoshi <ko1@a...>
Date: Wed, 24 Apr 2019 21:34:44 +0900 (JST)
Subject: [ruby-changes:55505] Nobuyoshi Nakada:f1a52d96a5 (trunk): Defer setting gc stress until inits =done=
Nobuyoshi Nakada 2019-04-24 12:52:57 +0900 (Wed, 24 Apr 2019) New Revision: f1a52d96a5 https://git.ruby-lang.org/ruby.git/commit/?id=3Df1a52d96a5 Log: Defer setting gc_stress until inits done = [Bug #15784] Modified files: gc.c inits.c test/ruby/test_gc.rb= From f1a52d96a59c63d46cb23af60cdcaf38e30e0512 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 24 Apr 2019 12:52:57 +0900 Subject: Defer setting gc_stress until inits done [Bug #15784] diff --git a/gc.c b/gc.c index 8f59f19..a12854d 100644 --- a/gc.c +++ b/gc.c @@ -2571,6 +2571,8 @@ Init_heap(void) https://github.com/ruby/ruby/blob/trunk/#L2571 objspace->id_to_obj_tbl = st_init_numtable(); objspace->obj_to_id_tbl = st_init_numtable(); + dont_gc = 1; + gc_stress_set(objspace, ruby_initial_gc_stress); #if RGENGC_ESTIMATE_OLDMALLOC @@ -2584,6 +2586,14 @@ Init_heap(void) https://github.com/ruby/ruby/blob/trunk/#L2586 finalizer_table = st_init_numtable(); } +void +Init_gc_stress(void) +{ + rb_objspace_t *objspace = &rb_objspace; + + dont_gc = 0; +} + typedef int each_obj_callback(void *, void *, size_t, void *); struct each_obj_args { diff --git a/inits.c b/inits.c index f730903..ad34223 100644 --- a/inits.c +++ b/inits.c @@ -67,5 +67,6 @@ rb_call_inits(void) https://github.com/ruby/ruby/blob/trunk/#L67 CALL(vm_trace); CALL(vm_stack_canary); CALL(ast); + CALL(gc_stress); } #undef CALL diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 8f77f49..5dea1b2 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -384,6 +384,10 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/#L384 end; end + def test_gc_stress_at_startup + assert_in_out_err([{"RUBY_DEBUG"=>"gc_stress"}], '', [], [], '[Bug #15784]', success: true) + end + def test_gc_disabled_start begin disabled = GC.disable -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/