DL::Symbol#call dumps core

e$B$3$s$K$A$O!"e(B sheepman e$B$G$9!#e(B

dl(1.8e$B$KIUB0$NJ}e(B)e$B$N%^%K%e%"%k$r=q$$$F$$$F5$$,$D$$$?$s$G$9$,!"e(B
e$B<!$N$h$&$K$9$k$He(B core e$B$rEG$-$^$9!#e(B

strlast = DL.callback(‘IS’){|s|
s[-1]
}
p strlast.call(“abcd”)[0].chr
DL.remove_callback(strlast)
p strlast.call(“abcd”)[0].chr

$ ruby-1.8 -vrdl/import t.rb
ruby 1.8.6 (2007-03-05 patchlevel 5000) [i686-linux]
“d”
t.rb:9: [BUG] Segmentation fault
ruby 1.8.6 (2007-03-05) [i686-linux]

zsh: abort ruby-1.8 -vrdl/import t.rb

e$B0J2<$O%Q%C%A$G$9!#e(B

Index: mkcallback.rb

— mkcallback.rb (revision 12023)
+++ mkcallback.rb (working copy)
@@ -31,6 +31,9 @@
subst_code,
“”,
" obj = rb_hash_aref(DLFuncTable,
rb_assoc_new(INT2NUM(#{rettype.to_s}),INT2NUM(#{fnum.to_s})));",

  • " if(NIL_P(obj))",
  • " rb_raise(rb_eDLError, “callback funciton does not exist in
    DL::FuncTable”);",
  • " Check_Type(obj, T_ARRAY);",
    " proto = rb_ary_entry(obj, 0);",
    " proc = rb_ary_entry(obj, 1);",
    " Check_Type(proto, T_STRING);",

At Sun, 11 Mar 2007 12:09:59 +0900,
sheepman wrote:

$ ruby-1.8 -vrdl/import t.rb
ruby 1.8.6 (2007-03-05 patchlevel 5000) [i686-linux]
“d”
t.rb:9: [BUG] Segmentation fault
ruby 1.8.6 (2007-03-05) [i686-linux]

zsh: abort ruby-1.8 -vrdl/import t.rb

以下はパッチです。

 ありがとうございます。エラーメッセージだけ修正してコミット
しました。

 1.9 の方(DL2)は該当部分がないのでそのままです。上のコードも
動きませんが、互換レイヤがないと移行がつらいかもしれませんね。


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”