[#37248] [Feature:1.9] Enumerator#inspect — "Yusuke ENDOH" <mame@...>

遠藤です。

12 messages 2008/12/02

[#37337] [Feature #841] Object#self — "rubikitch ." <redmine@...>

Feature #841: Object#self

13 messages 2008/12/09

[#37513] Current status of 1.9.1 RC1's issues — "Yugui (Yuki Sonoda)" <yugui@...>

Hi, folks

14 messages 2008/12/20
[#37516] Re: Current status of 1.9.1 RC1's issues — Masatoshi SEKI <m_seki@...> 2008/12/20

咳といいます。

[#37576] [BUG:trunk] encoding for stdio's — "Yugui (Yuki Sonoda)" <yugui@...>

Yuguiです。

11 messages 2008/12/24

[ruby-dev:37587] [Bug: trunk] module_function中のsuperでSystemStackError

From: wanabe <s.wanabe@...>
Date: 2008-12-24 15:47:15 UTC
List: ruby-dev #37587
ワナベと申します。

以下のスクリプトでSystemStackErrorになります。

$ ./ruby -ve '
module Foo
  def foo
    super
  end
  module_function :foo
end
Foo.foo
'
ruby 1.9.1 (2008-12-24 patchlevel-5000 trunk 20971) [i386-mingw32]
-e:4:in `foo': stack level too deep (SystemStackError)
        from -e:4:in `foo'
        from -e:4:in `foo'
        from -e:4:in `foo'
        from -e:4:in `foo'
        from -e:4:in `foo'
        from -e:4:in `foo'
        from -e:4:in `foo'
        from -e:4:in `foo'
         ... 8720 levels...
        from -e:4:in `foo'
        from -e:4:in `foo'
        from -e:4:in `foo'
        from -e:8:in `<main>'

vm_search_normal_superclass() がスーパークラスを見つけられなかったときに
渡された元クラスをそのまま返しているのが原因のように思います。
この場合の適切なスーパークラスを決める方法がわからなかったので、
0を返すようにしてパッチを書いてみました。
副作用で [Bug #730] も SystemStackError にならなくなるようです。

Index: insns.def
===================================================================
--- insns.def	(revision 20971)
+++ insns.def	(working copy)
@@ -1015,13 +1015,15 @@
     rb_block_t *blockptr = !(op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ?
GET_BLOCK_PTR() : 0;
     int num = caller_setup_args(th, GET_CFP(), op_flag, op_argc,
blockiseq, &blockptr);
     VALUE recv, klass;
-    NODE *mn;
+    NODE *mn = 0;
     ID id;
     const VALUE flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;

     recv = GET_SELF();
     vm_search_superclass(GET_CFP(), GET_ISEQ(), recv, TOPN(num), &id, &klass);
-    mn = rb_method_node(klass, id);
+    if (klass) {
+	mn = rb_method_node(klass, id);
+    }

     CALL_METHOD(num, blockptr, flag, id, mn, recv);
 }
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 20971)
+++ vm_insnhelper.c	(working copy)
@@ -1179,6 +1179,9 @@
 	    }
 	    k = RCLASS_SUPER(k);
 	}
+	if (!k) {
+	    klass = 0;
+	}
     }
     return klass;
 }

-- 
ワナベ

In This Thread

Prev Next