From: Yusuke ENDOH Date: 2008-01-28T21:00:32+09:00 Subject: [ruby-dev:33470] next in while may dumps core 遠藤と申します。 1.9 が以下で落ちます。また、next を redo に変えても落ちます。 $ ./ruby -e ' def foo while true begin yield next rescue end end rescue retry end foo { raise } ' -e:5: [BUG] Segmentation fault ruby 1.9.0 (2008-01-28 revision 15294) [i686-linux] -- control frame ---------- c:0004 p:0003 s:0008 b:0009 l:000008 d:000008 METHOD -e:5 c:0003 p:0012 s:0006 b:0006 l:000005 d:000005 TOP -e:14 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH :inherited c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP :17 --------------------------- DBG> : "-e:14:in `
'" -- backtrace of native function call (Use addr2line) -- 0x80ef855 0x810e2ce 0x810e32b 0x80be760 0xffffe440 0x80ed264 0x80ed59d 0x805a7f9 0x805e940 0x8058221 0xb7e00ea8 0x8058131 ------------------------------------------------------- アボートしました あんまりちゃんと追っていませんが、NODE_NEXT や _REDO を while の中で コンパイルするとき、poped を無視しているため発生する問題のようです。 Index: compile.c =================================================================== --- compile.c (revision 15294) +++ compile.c (working copy) @@ -3049,6 +3049,10 @@ ADD_ADJUST(ret, nd_line(node), iseq->compile_data->redo_label); ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->start_label); ADD_ADJUST_RESTORE(ret, splabel); + + if (!poped) { + ADD_INSN(ret, nd_line(node), putnil); + } } else if (iseq->compile_data->end_label) { LABEL *splabel = NEW_LABEL(0); @@ -3110,6 +3114,10 @@ add_ensure_iseq(ret, iseq); ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->redo_label); ADD_ADJUST_RESTORE(ret, splabel); + + if (!poped) { + ADD_INSN(ret, nd_line(node), putnil); + } } else if (iseq->type == ISEQ_TYPE_EVAL) { redo_in_eval: -- Yusuke ENDOH