[前][次][番号順一覧][スレッド一覧][生データ]

yarv-dev:709

From: Minero Aoki <aamine loveruby.net>
Date: Mon, 26 Dec 2005 17:14:41 +0900 (JST)
Subject: [yarv-dev:709] open> super undef'ed method

青木です。

undef されたメソッドを super で呼ぶと落ちます。

~/c/yarv % cat t
class A
  def foo() end
end

class B < A
  undef foo
end

class C < B
  def foo
    super
  end
end

C.new.foo

~/c/yarv % ./miniruby t
t:11: DBG> : "t:15:in `<main>'"
-- stack frame ------------
0x2a95ee2010 (0000): 00000001
0x2a95ee2018 (0001): 00000004
0x2a95ee2020 (0002): 00000001
0x2a95ee2028 (0003): 2a95eaee10
0x2a95ee2030 (0004): 00000004
0x2a95ee2038 (0005): 00000001 <- lfp <- dfp
0x2a95ee2040 (0006): 00000004 <- bp
-- control frame ----------
c:0004 p:0005 s:0007 b:0006 l:0005 d:0005 METHOD i:foo      s:         -  
c:0003 p:0052 s:0003 b:0003 l:0002 d:0002 TOP    i:<main>   s:         -  
c:0002 p:-001 s:0001 b:0001 l:0000 d:0000 FINISH i:-        s:         -  
c:0001 p:-001 s:0000 b:-001 l:0000 d:0000 ------ i:-        s:         -  
---------------------------
[BUG] Segmentation fault
ruby 1.9.0 (2005-11-18) [x86_64-linux]

zsh: 3129 abort (core dumped)  ./miniruby t


いちおうパッチも作ってみました。


Index: vm_macro.def
===================================================================
--- vm_macro.def	(revision 330)
+++ vm_macro.def	(working copy)
@@ -256,6 +256,9 @@
       val = eval_method_missing(th, id, recv, num, stat);
     }
   }
+  else if(mn->nd_body == 0){
+    eval_method_missing(th, id, recv, num, NOEX_SUPER);
+  }
   else if(!(flag & VM_CALL_FCALL_BIT) &&
           mn->nd_noex & NOEX_PRIVATE){
     int stat = NOEX_PRIVATE;


パッチ後

~/c/yarv % ./miniruby t
t:11:in `method_missing': super: no superclass method `foo' (NoMethodError)
        from t:11:in `foo'
        from t:15:in `<main>'

--
青木峰郎

-- 
ML: yarv-dev quickml.atdot.net
使い方: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]

->     709 2005-12-26 17:14 [aamine loveruby.net ] open> super undef'ed method             
       710 2005-12-26 17:22 ┣[aamine loveruby.net ]                                       
       714 2005-12-27 02:11 ┗[ko1 atdot.net       ] fixed> Re: open> super undef'ed method
       719 2005-12-27 16:29  ┗[aamine loveruby.net ] close> Re: super undef'ed method