From: Yusuke ENDOH Date: 2008-08-28T20:52:05+09:00 Subject: [ruby-dev:36029] Re: [Bug #513] Tempfile yields [BUG] Stack consistency error 遠藤です。 2008/08/28 11:18 Shyouhei Urabe : > zsh % gdb --args ~/target/trunk/bin/ruby -rtempfile -ve > Tempfile.open("") do |f| > f.write "\n"; > f.rewind; > g = Tempfile.new ""; > f.each {break}; > g.rewind; > end > ' (snip) > -e:1: [BUG] Stack consistency error (sp: 16, bp: 15) (snip) 簡単にできました。 $ ./ruby -e ' class Foo define_method(:foo) do |&b| b.call end end Foo.new.foo do break end ' -e:8: [BUG] Stack consistency error (sp: 7, bp: 6) ruby 1.9.0 (2008-08-28 revision 18895) [i686-linux] -- control frame ---------- c:0003 p:0032 s:0007 b:0006 l:001084 d:001084 TOP -e:8 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 --------------------------- DBG> : "-e:8:in `
'" -- backtrace of native function call (Use addr2line) -- 0x8112df4 0x813e18e 0x813e1d8 0x810bc5f 0x810c3a4 0x810c58c 0x805aa3f 0x805bd46 0x8058e70 0xb7e21ea8 0x8058d51 ------------------------------------------------------- Aborted BMETHOD 中で throw する可能性があるので、BMETHOD を呼び出す前に スタックを縮めるべきかと思います。 Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 18895) +++ vm_insnhelper.c (working copy) @@ -519,8 +519,8 @@ } case NODE_BMETHOD:{ VALUE *argv = cfp->sp - num; + cfp->sp += - num - 1; val = vm_call_bmethod(th, id, node->nd_cval, recv, klass, num, argv, blockptr); - cfp->sp += - num - 1; break; } case NODE_ZSUPER:{ -- Yusuke ENDOH