From: Yusuke ENDOH Date: 2008-05-22T23:20:20+09:00 Subject: [ruby-dev:34806] peephole_optimize ignores ADJUST 遠藤です。 以下で SEGV します。 $ ./ruby -e ' 1.times do begin ensure redo unless false end end ' -e:4: [BUG] Segmentation fault ruby 1.9.0 (2008-05-22 revision 16531) [i686-linux] -- stack frame ------------ -- control frame ---------- c:0006 p:0001 s:302711808 b:0011 l:000005 d:000010 BLOCK -e:4 c:0005 p:---- s:0011 b:0011 l:000010 d:000010 FINISH :class_eval c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC :times c:0003 p:0008 s:0006 b:0006 l:000005 d:000005 TOP -e:2 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH :private_class_method c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP :17 --------------------------- Segmentation fault ISEQ_ELEMENT_ADJUST が追加されたのに、peephole_optimize が ISEQ_ELEMENT_INSN しか探さないことが原因のようです。 Index: compile.c =================================================================== --- compile.c (revision 16534) +++ compile.c (working copy) @@ -1362,7 +1362,7 @@ list = lobj->link.next; while (list) { - if (list->type == ISEQ_ELEMENT_INSN) { + if (list->type == ISEQ_ELEMENT_INSN || list->type == ISEQ_ELEMENT_ADJUST) { break; } list = list->next; @@ -1376,7 +1376,7 @@ LINK_ELEMENT *list = iobj->link.next; while (list) { - if (list->type == ISEQ_ELEMENT_INSN) { + if (list->type == ISEQ_ELEMENT_INSN || list->type == ISEQ_ELEMENT_ADJUST) { return list; } list = list->next; @@ -1390,7 +1390,7 @@ LINK_ELEMENT *list = iobj->link.prev; while (list) { - if (list->type == ISEQ_ELEMENT_INSN) { + if (list->type == ISEQ_ELEMENT_INSN || list->type == ISEQ_ELEMENT_ADJUST) { return list; } list = list->prev; -- Yusuke ENDOH