From: Nobuyoshi Nakada Date: 2007-08-20T23:29:07+09:00 Subject: [ruby-dev:31537] Re: simultaneous exceptions dump core なかだです。 At Mon, 20 Aug 2007 22:16:57 +0900, Yusuke ENDOH wrote in [ruby-dev:31533]: > 1. #10 ruby_thread_init 中で #9 th_init2 が呼ばれる (th->vm 未初期化) > 2. #9 th_init2 中の ALLOC_N で GC が起きる > 3. なぜか ruby_thread_init で初期化しようとしているスレッドが free される > 4. #6 thread_free 中の th->vm->main_thread の参照で落ちる > > # ちゃんと追えてないのですが、上記のどこかでコンテキストスイッチも > # 混ざってるような気がします。 > > > 試しに #11 rb_thread_alloc の > VALUE self = thread_alloc(klass); > を VALUE volatile self = ... にしてみましたが、症状はかわりませんでした。 末尾呼出の最適化でself自体が消えてしまっているのかもしれません。 これでどうでしょうか。 Index: vm.c =================================================================== --- vm.c (revision 13116) +++ vm.c (working copy) @@ -1611,8 +1611,9 @@ thread_alloc(VALUE klass) static void -th_init2(rb_thread_t *th) +th_init2(rb_thread_t *th, VALUE self) { MEMZERO(th, rb_thread_t, 1); + th->self = self; /* allocate thread stack */ th->stack_size = RUBY_VM_THREAD_STACK_SIZE; @@ -1643,7 +1644,7 @@ th_init2(rb_thread_t *th) static void -th_init(rb_thread_t *th) +th_init(rb_thread_t *th, VALUE self) { - th_init2(th); + th_init2(th, self); } @@ -1655,6 +1656,5 @@ ruby_thread_init(VALUE self) GetThreadPtr(self, th); - th_init(th); - th->self = self; + th_init(th, self); th->vm = vm; @@ -1804,5 +1804,5 @@ Init_BareVM(void) ruby_current_vm = vm; - th_init2(th); + th_init2(th, 0); th->vm = vm; th->machine_stack_start = rb_gc_stack_start; -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦