From: nobu@... Date: 2004-12-23T00:51:18+09:00 Subject: [ruby-dev:25286] Re: Process.groups= dumps core again なかだです。 At Wed, 22 Dec 2004 23:59:59 +0900, Tanaka Akira wrote in [ruby-dev:25285]: > 次のようにすると core を吐きます。 > > % ./ruby -e ' > ary = [1] * 0x200000 > ary.shift(0x200000-10) > ary[0] = Object.new > class << ary[0]; self end.send(:define_method, :to_str) { > ary.replace [] > GC.start > "root" > } > Process.groups = ary > ' > -e:10: [BUG] Segmentation fault > ruby 1.9.0 (2004-12-22) [i686-linux] 思い付くのは 1. 引数の長さが変わったか毎回チェックする 2. ary_make_shared()でfreezeされたArrayを使う (rb_str_new4()と同様) の二つくらいですが、以下のパッチは1のほうです。 * process.c (proc_setgroups): check if the argument lenght is modified. Index: process.c =================================================================== RCS file: /cvs/ruby/src/ruby/process.c,v retrieving revision 1.125 diff -U2 -p -r1.125 process.c --- process.c 8 Dec 2004 11:14:51 -0000 1.125 +++ process.c 22 Dec 2004 15:48:15 -0000 @@ -2698,6 +2698,6 @@ proc_setgroups(VALUE obj, VALUE ary) groups = ALLOCA_N(gid_t, ngroups); - for (i = 0; i < ngroups; i++) { + for (i = 0; i < ngroups && i < RARRAY(ary)->len; i++) { VALUE g = RARRAY(ary)->ptr[i]; -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦