From: Akinori MUSHA Date: 2007-03-12T01:19:53+09:00 Subject: [ruby-dev:30535] Re: DL::PtrData#to_a dumps core --pgp-sign-Multipart_Mon_Mar_12_01:19:53_2007-1 Content-Type: text/plain; charset=ISO-2022-JP ttateさんにCCします。 At Mon, 12 Mar 2007 00:14:20 +0900, sheepman wrote: > こんばんは、sheepman です。 > > DL::PtrData が以下のようにすると core を吐きます。 > PtrData クラスはポインターのラッパーですから、扱い次第では > core を吐いてしまうのは仕方がないと思うのですが、以下の場合に core を > 吐いてしまうのは、バグなんじゃないかと思います。 > > 仕様なんでしょうか? r4831 | ttate | 2003-10-22 23:29:20 +0900 (Wed, 22 Oct 2003) | 2 lines Bugfix for PR#1196 というコミットに何か意図がありそうですが、どうでしょうね。 > とりあえず、パッチを添付します。 > > $ cat t2.rb > require "dl" > sp = ['a', 'b', 'c'].to_ptr > sp.to_a('S') > > $ ruby-1.8 -v t2.rb > ruby 1.8.6 (2007-03-05 patchlevel 5000) [i686-linux] > t2.rb:3: [BUG] Segmentation fault > ruby 1.8.6 (2007-03-05) [i686-linux] > > zsh: abort ruby-1.8 -v t2.rb > > $ svn diff ext/dl/ptr.c > Index: ext/dl/ptr.c > =================================================================== > --- ext/dl/ptr.c (revision 12023) > +++ ext/dl/ptr.c (working copy) > @@ -344,7 +344,7 @@ > n = data->size / sizeof(void*); > break; > case 'S': case 's': > - for (n=0; ((void**)(data->ptr))[n]; n++) {}; > + n = data->size / sizeof(char*); > break; > default: > n = 0; > > -- > sheepman / TAMURA Takashi > sheepman@sheepman.sakura.ne.jp -- / /__ __ 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" --pgp-sign-Multipart_Mon_Mar_12_01:19:53_2007-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQBF9Cwpkgvvx5/Z4e4RAgHWAJ9buBHVDT1qU6eak17A+iL6JUeU3gCfR/dX RXX2aKKbqhNWa559TIoZ6Cg= =olZv -----END PGP SIGNATURE----- --pgp-sign-Multipart_Mon_Mar_12_01:19:53_2007-1--