From: Robert Klemme Date: 2007-06-12T23:25:04+09:00 Subject: Re: Benchmark segfault [Was: Array#inject to create a hash versus Hash[*array.collect{}.flatten] ] On 12.06.2007 16:16, Florian Frank wrote: > Robert Klemme wrote: >> I believe it's the star operator: >> >> 13:10:22 [Temp]: ruby -e 'Hash[*Array.new(ARGV.shift.to_i) ]' 1000000 >> 13:10:35 [Temp]: ruby -e 'Hash[*Array.new(ARGV.shift.to_i) ]' 10000000 >> -e:1: [BUG] Segmentation fault >> ruby 1.8.6 (2007-03-13) [i386-cygwin] >> >> Aborted (core dumped) >> 13:10:39 [Temp]: ruby -e 'def f(*a) end; f(*Array.new(ARGV.shift.to_i))' >> 1000000 >> 13:11:09 [Temp]: ruby -e 'def f(*a) end; f(*Array.new(ARGV.shift.to_i))' >> 10000000 >> -e:1: [BUG] Segmentation fault >> ruby 1.8.6 (2007-03-13) [i386-cygwin] >> >> Aborted (core dumped) >> 13:11:14 [Temp]: uname -a >> CYGWIN_NT-5.2-WOW64 PDBXPWSRK38 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 >> Cygwin >> 13:11:36 [Temp]: ruby --version >> ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-cygwin] > > The reason for this problem is, that the stack is used to pass A LOT of > arguments to the Hash.[] method. If the stack size of the executed process isn't > big enough (check your resource limits), this can lead to crashes. That was what I was guessing. However, I haven't enough insight to verify. There is at least one point that causes me doubt: the array can be handled and stored like any other array, so it should be on the heap (or it is implicitly moved there). Kind regards robert