Issue #4855 has been reported by Tomoyuki Chikanaga.

----------------------------------------
Bug #4855: rb_context_t::saved_thread::machine_stack_(start|end) should be cleared
http://redmine.ruby-lang.org/issues/4855

Author: Tomoyuki Chikanaga
Status: Open
Priority: Normal
Assignee: Tomoyuki Chikanaga
Category: core
Target version: 1.9.x
ruby -v: ruby 1.9.3dev (2011-06-08 trunk 31957) [x86_64-darwin10.7.0]


?永?????????????????説??????????????????????ruby-dev??失礼?????????

#4827 ??調?????????????????????? valgrind ?????????????????以???????????
?正????????? machine stack ??????? mark ????????????????????????????????????????????????
(????????? FIBER_USE_NATIVE=0 ???????????????)???

==27771== Invalid read of size 4
==27771==    at 0x809AC1E: mark_locations_array (gc.c:1373)
==27771==    by 0x809ACED: gc_mark_locations (gc.c:1389)
==27771==    by 0x809D018: rb_gc_mark_machine_stack (gc.c:2498)
==27771==    by 0x819684E: rb_thread_mark (vm.c:1700)
==27771==    by 0x819FC05: cont_mark (cont.c:141)
==27771==    by 0x819FE09: fiber_mark (cont.c:268)
==27771==    by 0x809B6FF: gc_mark_children (gc.c:1813)
==27771==    by 0x809B27C: gc_mark (gc.c:1605)
==27771==    by 0x809B2B6: rb_gc_mark (gc.c:1611)
==27771==    by 0x8196790: rb_thread_mark (vm.c:1690)
==27771==    by 0x809B6FF: gc_mark_children (gc.c:1813)
==27771==    by 0x809B27C: gc_mark (gc.c:1605)
==27771==    by 0x809B2B6: rb_gc_mark (gc.c:1611)
==27771==    by 0x819620E: vm_mark_each_thread_func (vm.c:1493)
==27771==    by 0x8136FD9: st_foreach (st.c:747)
==27771==    by 0x819627B: rb_vm_mark (vm.c:1516)
==27771==    by 0x809B6FF: gc_mark_children (gc.c:1813)
==27771==    by 0x809B27C: gc_mark (gc.c:1605)
==27771==    by 0x809B2B6: rb_gc_mark (gc.c:1611)
==27771==    by 0x809CC23: gc_marks (gc.c:2423)
==27771==    by 0x809CE98: garbage_collect (gc.c:2474)
==27771==    by 0x8099C08: garbage_collect_with_gvl (gc.c:689)
==27771==    by 0x8099CB6: vm_malloc_prepare (gc.c:719)
==27771==    by 0x8099CE9: vm_xmalloc (gc.c:751)
==27771==    by 0x8099EBB: ruby_xmalloc2 (gc.c:831)
==27771==    by 0x81A005C: cont_save_machine_stack (cont.c:350)
==27771==    by 0x81A0E70: fiber_store (cont.c:1187)
==27771==    by 0x81A10D5: fiber_switch (cont.c:1277)
==27771==    by 0x81A113A: rb_fiber_transfer (cont.c:1292)
==27771==    by 0x81A11E4: rb_fiber_yield (cont.c:1311)
==27771==    by 0x81A1293: rb_fiber_s_yield (cont.c:1389)
==27771==    by 0x8185238: call_cfunc (vm_insnhelper.c:317)
==27771==    by 0x8185B7C: vm_call_cfunc (vm_insnhelper.c:404)
==27771==    by 0x8186091: vm_call_method (vm_insnhelper.c:526)
==27771==    by 0x818A6C7: vm_exec_core (insns.def:1012)
==27771==    by 0x8195705: vm_exec (vm.c:1163)
==27771==    by 0x8194404: invoke_block_from_c (vm.c:574)
==27771==    by 0x81945BE: rb_vm_invoke_proc (vm.c:620)
==27771==    by 0x81A0C93: rb_fiber_start (cont.c:1121)
==27771==    by 0x808AF19: ruby_exec_internal (eval.c:213)
==27771==    by 0x808AFF9: ruby_exec_node (eval.c:260)
==27771==    by 0x808AFD3: ruby_run_node (eval.c:253)
==27771==    by 0x805B1CD: main (main.c:38)
==27771==  Address 0xbed8aa48 is not stack'd, malloc'd or (recently) free'd

????????? rb_context_t::saved_thread ??? thread ???????????????????
????????? machine_stack_(start|end) ??? 0 ???????????????????? vm stack ??確??????????? GC ???走??
???????????????????????? saved_thread->machine_stack_end ???????????????????????????
??????????尾?????????伸????????????????????????????? mark ????????????????????????
?度????????????????? machine stack ???伸??????????????????????正??????????????
??????????????????????????????????????? mark ????????????????修正??????????????????????

????????? saved_thread ?????????????????常??????? machine_stack_(start|end) ????????????????????????????????
???? __ia64 ???? machine_register_stack_(start|end) ??????????????????????????????????????????????????
?????? IA64 ???????使???????????????確????????

saved_thread.machine_stack_(start|end) ?????????????? cont.c ???読????以???????????
???解????????????????????????????????????????????????込?????????????
?????????????????????? Fiber ??????????????????????????????????????????????????????????????????????稿?????????

 * FIBER_USE_NATIVE=0 ????(setjmp/longjmp ?????)
saved_thread.machine_stack_(start|end) ?????????????常?? 0 ????????

 * FIBER_USE_NATIVE=1 ????
saved_thread.machine_stack_end ?????????????常?? 0 ????????
saved_thread.machine_stack_start ??? Thread ?????中?? Fiber ???????????
ucontext_t::uc_stack ?????????????????????????
saved_thread ??????????????? 0 ?????????? fiber_setcontext() ????????
??????????????大?夫??




-- 
http://redmine.ruby-lang.org