зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
6fa2980e53
Коммит
6aa2aabd8b
|
@ -1,3 +1,10 @@
|
|||
Thu Oct 4 16:31:29 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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().
|
||||
|
||||
Thu Oct 4 11:43:28 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* thread_pthread.c (ruby_init_stack): round stack limit to page size
|
||||
|
|
25
gc.c
25
gc.c
|
@ -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);
|
||||
|
||||
|
@ -2830,13 +2834,25 @@ 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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче