yarv-dev:1079
From: SASADA Koichi <ko1 atdot.net>
Date: Thu, 17 Aug 2006 11:24:36 +0900
Subject: [yarv-dev:1079] fixed> Re: open> vm_mark and th->machine_stack_start
ささだです. ううむ.このタイミングで gc が起こることを想定していませんでした.そう いうことってありました? この片のタイミングでは,malloc の返り値を見て いても,結局 segv するんだろうな.例外の機構とかが動かないから. ということで,なんとなく直しました.テストしてないけど. sheepman wrote: > こんばんは、sheepman です。 > [yarv-dev:1066] のつづきです。 > Init_yarvcore が呼ばれる前に、vm_mark が呼ばれると > SEGV します。同じように、Init_yarvcore が呼ばれる前に、 > th->machine_stack_start を 0 のまま GC の時に使うと > SEGV します。 > > とりあえず以下のようなチェックが必要だと思います。stack_start を > この位置で取るのは明らかにおかしいんですが、どうすればいいのか良く > 分からないので取り敢えず書いておきました。main を呼んだらすぐに、 > グローバル変数として stack_start を保存しておく必要があるのだと > 思います。 > > $ svn diff --diff-cmd diff -x '-ub --expand-tabs' yarvcore.c > Index: yarvcore.c > =================================================================== > --- yarvcore.c (revision 527) > +++ yarvcore.c (working copy) > @@ -252,7 +252,9 @@ > GC_INFO("-------------------------------------------------\n"); > if (ptr) { > yarv_vm_t *vm = ptr; > + if(vm->living_threads){ > st_foreach(vm->living_threads, vm_mark_each_thread_func, 0); > + } > MARK_UNLESS_NULL(vm->thgroup_default); > MARK_UNLESS_NULL(vm->mark_object_ary); > } > @@ -1015,11 +1017,13 @@ > /* initialize main thread */ > yarv_vm_t *vm = ALLOC(yarv_vm_t); > yarv_thread_t *th = ALLOC(yarv_thread_t); > + VALUE stack_start; > > vm_init2(vm); > theYarvVM = vm; > > th_init2(th); > th->vm = vm; > + th->machine_stack_start = &stack_start; > yarv_set_current_running_thread_raw(th); > } > > -- // SASADA Koichi at atdot dot net -- ML: yarv-dev quickml.atdot.net Info: http://www.atdot.net/~ko1/quickml
1067 2006-07-23 22:05 [sheepman sheepman.sa] open> vm_mark and th->machine_stack_start -> 1079 2006-08-17 11:24 ┗[ko1 atdot.net ] fixed> Re: open> vm_mark and th->machine_stack_start 1082 2006-08-17 17:17 ┗[matz ruby-lang.org ]