From: "Ara.T.Howard" Date: 2005-07-21T22:50:00+09:00 Subject: Re: [BUG] Segmentation fault with a threads/forks script On Thu, 21 Jul 2005, Lucas Nussbaum wrote: > Hi, > > I experience a reproducable crash (each time) with prunner.rb at > http://blop.info/bazaar/prunner.rb. The script starts several commands > at the same time. When running with a large number of commands, it > exits with : > > ./prunner.rb:51: [BUG] Segmentation fault > ruby 1.8.2 (2005-04-11) [i386-linux] > > Aborted > > To reproduce, create a large file with one command per line. > for i in $(seq 1 2000); do echo hostname done > cmds > Then run prunner.rb like this : > cat cmds |head -n 1500 |./prunner.rb > 1500 can be increased if it doesn't crash for you. > > Of course, I expect it to go wrong at some time, but it could probably > do this in a cleaner way. > > Can somebody confirm the bug ? Or better, fix it ? :-) seems to work on 1.8.2 for values around 1000: [ahowward@localhost ~]$ wget http://blop.info/bazaar/prunner.rb --07:25:29-- http://blop.info/bazaar/prunner.rb => `prunner.rb' Resolving blop.info... 85.68.8.93 Connecting to blop.info[85.68.8.93]:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2,125 [text/plain] 100%[======================================================================================================================================>] 2,125 --.--K/s 07:25:29 (42.22 MB/s) - `prunner.rb' saved [2,125/2,125] [ahoward@localhost ~]$ for i in $(seq 1 2000);do echo 'date'; done > cmds [ahoward@localhost ~]$ wc -l cmds 2000 cmds [ahoward@localhost ~]$ ruby prunner.rb < cmds >/dev/null prunner.rb:47:in `popen': Too many open files - date 2>&1 (Errno::EMFILE) from prunner.rb:47 from prunner.rb:47:in `each' from prunner.rb:47 [ahoward@localhost ~]$ head -1000 cmds |ruby prunner.rb >/dev/null [ahoward@localhost ~]$ echo $? 0 [ahoward@localhost ~]$ ruby -v ruby 1.8.2 (2005-02-12) [i686-linux] [ahoward@localhost ~]$ uname -srm Linux 2.6.12-1.1372_FC3 i686 [ahoward@localhost ~]$ cat /etc/redhat-release Fedora Core release 3 (Heidelberg) and on 1.9: harp:~ > wget http://blop.info/bazaar/prunner.rb --07:42:37-- http://blop.info/bazaar/prunner.rb => `prunner.rb.1' Resolving blop.info... 85.68.8.93 Connecting to blop.info[85.68.8.93]:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2,125 [text/plain] 100%[======================================================================================================================================>] 2,125 --.--K/s 07:42:37 (343.01 KB/s) - `prunner.rb.1' saved [2,125/2,125] harp:~ > for i in $(seq 1 2000);do echo 'date'; done > cmds harp:~ > wc -l cmds 2000 cmds harp:~ > ruby prunner.rb < cmds >/dev/null prunner.rb:47:in `popen': Too many open files - date 2>&1 (Errno::EMFILE) from prunner.rb:47 from prunner.rb:47:in `each' from prunner.rb:47 harp:~ > head -1000 cmds|ruby prunner.rb >/dev/null harp:~ > echo $? 0 harp:~ > ruby -v ruby 1.9.0 (2005-05-16) [i686-linux] harp:~ > uname -srm Linux 2.4.21-32.0.1.EL i686 harp:~ > cat /etc/redhat-release Red Hat Enterprise Linux WS release 3 (Taroon Update 5) did you compile ruby yourself or use some installer/package-manager? cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================