diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-04 07:31:31 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-04 07:31:31 +0000 |
commit | 6aa2aabd8b8c948d1f9eb2fb367ef24a24f237ce (patch) | |
tree | bf295ea655dc82e9a07844d015aa86555840f1d1 /gc.c | |
parent | 6fa2980e53c168ccfd08fdfdcc3444cdda6b3bcc (diff) | |
download | ruby-6aa2aabd8b8c948d1f9eb2fb367ef24a24f237ce.tar.gz |
gc.c: self-referencing finalizers
* gc.c (rb_objspace_call_finalizer): mark self-referencing finalizers
before run finalizers, to fix SEGV from btest on 32bit.
* gc.c (gc_mark_stacked_objects): extract from gc_marks().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -358,6 +358,7 @@ static int garbage_collect(rb_objspace_t *); static int gc_lazy_sweep(rb_objspace_t *); static void mark_tbl(rb_objspace_t *, st_table *); static void rest_sweep(rb_objspace_t *); +static void gc_mark_stacked_objects(rb_objspace_t *); static double getrusage_time(void); static inline void gc_prof_timer_start(rb_objspace_t *); @@ -1483,6 +1484,9 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace) RVALUE *final_list = 0; size_t i; + mark_tbl(objspace, finalizer_table); + gc_mark_stacked_objects(objspace); + /* run finalizers */ rest_sweep(objspace); @@ -2831,12 +2835,24 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr) } static void +gc_mark_stacked_objects(rb_objspace_t *objspace) +{ + mark_stack_t *mstack = &objspace->mark_stack; + VALUE obj = 0; + + if (!mstack->index) return; + while (pop_mark_stack(mstack, &obj)) { + gc_mark_children(objspace, obj); + } + shrink_stack_chunk_cache(mstack); +} + +static void gc_marks(rb_objspace_t *objspace) { struct gc_list *list; rb_thread_t *th = GET_THREAD(); - mark_stack_t *mstack = &objspace->mark_stack; - VALUE obj = 0; + gc_prof_mark_timer_start(objspace); objspace->heap.live_num = 0; @@ -2870,10 +2886,7 @@ gc_marks(rb_objspace_t *objspace) rb_gc_mark_unlinked_live_method_entries(th->vm); /* marking-loop */ - while (pop_mark_stack(mstack, &obj)) { - gc_mark_children(objspace, obj); - } - shrink_stack_chunk_cache(mstack); + gc_mark_stacked_objects(objspace); gc_prof_mark_timer_stop(objspace); } |