From: KUBO Takehiro Date: 2007-02-21T22:33:56+09:00 Subject: [ruby-dev:30396] unsupported: th_call0 in 1.9 久保です。 ruby 1.9 で以下の条件のとき、[BUG] unsupported: th_call0 となりました。 1. private なメソッドをサブクラスで public にする。 2. 拡張ライブラリからサブクラスで public にしたメソッドを rb_funcall で呼び出す。 DateTime#hour がこのようなメソッドで、拡張ライブラリから呼び出そうと したらエラーになりました。ruby 1.8 では問題なく使えました。 以下、再現方法 = ソース3つ(extconf.rb, mytest.c, mytest.rb) extconf.rb: require 'mkmf' create_makefile('mytest') mytest.c: /* * class MyTest * def self.run(arg) * arg.run * end * end */ #include static VALUE mytest_run(VALUE klass, VALUE arg) { return rb_funcall(arg, rb_intern("run"), 0); } void Init_mytest() { VALUE cMyTest = rb_define_class("MyTest", rb_cObject); rb_define_singleton_method(cMyTest, "run", mytest_run, 1); } mytest.rb: require './mytest.so' class A def run 'OK' end private :run end class B < A public :run end puts MyTest.run(B.new) = 拡張ライブラリ mytest.so を作成して mytest.rb を実行 ruby extconf.rb make ruby mytest.rb = 実行結果 -- stack frame ------------ 0000 (0xb7caa008): 00000004 0001 (0xb7caa00c): 00000005 0002 (0xb7caa010): 00000004 0003 (0xb7caa014): 00000001 0004 (0xb7caa018): 00000004 0005 (0xb7caa01c): b7d74b70 0006 (0xb7caa020): b7d748f0 0007 (0xb7caa024): 00000004 0008 (0xb7caa028): 00000001 <- lfp <- dfp -- control frame ---------- c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC :run c:0003 p:0057 s:0005 b:0004 l:000003 d:000003 TOP mytest.rb:14 c:0002 p:---- s:0002 b:0002 l:000001 d:000001 FINISH c:0001 p:---- s:0000 b:-001 l:000000 d:000000 ------ --------------------------- DBG> : "mytest.rb:14:in `
'" -- backtrace of native function call (Use addr2line) -- 0x80d83da 0x80ef150 0x80d6fb2 0x805947f 0x8059936 0xb7e2f6b5 0x80d429e 0x80d666d 0x80d69b8 0x8058fdb 0x8059016 0x805c670 0x80567af 0xb7e4aea8 0x80566e1 ------------------------------------------------------- [BUG] unsupported: th_call0 ruby 1.9.0 (2007-02-21) [i686-linux] アボートしました