From: Kengo Matsuyama Date: 2009-03-31T17:42:18+09:00 Subject: [ruby-dev:38221] [Bug #1338] Kernel#select crashes when many files are opened Bug #1338: Kernel#select crashes when many files are opened http://redmine.ruby-lang.org/issues/show/1338 起票者: Kengo Matsuyama ステータス: Open, 優先度: Normal ruby -v: ruby 1.9.2dev (2009-03-31 trunk 23101) [i686-linux] 以下のコードがクラッシュします。 Process.setrlimit(Process::RLIMIT_NOFILE, 2048) fd = 2000.times.map { open("/bin/ls") } select([fd.last], [], [], 0) 添付したパッチで手元の環境では動くようになりましたが、 他の環境(win32 とか)での動作は分からないです。 また、具体的な再現コードは作れなかったのですが、 thread.c の do_select() の orig_read, orig_write, orig_except の扱いは、 バグを引き起こしそうです。(fd_set 型をそのまま使っている) 以下はクラッシュ時のログです。 $ ./ruby -e 'Process.setrlimit(Process::RLIMIT_NOFILE, 2048); fd = 2000.times.map { open("/bin/ls") }; select([fd.last], [], [], 0)' -e:1: [BUG] Segmentation fault ruby 1.9.2dev (2009-03-31 trunk 23101) [i686-linux] -- control frame ---------- c:0004 p:---- s:0014 b:0014 l:000013 d:000013 CFUNC :select c:0003 p:0072 s:0007 b:0007 l:00199c d:000e68 EVAL -e:1 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:00199c d:00199c TOP
:17 --------------------------- -e:1:in `
' -e:1:in `select' -- C level backtrace information ------------------------------------------- 0x81591a5 ./ruby(rb_vm_bugreport+0xb5) [0x81591a5] 0x819458e ./ruby [0x819458e] 0x8194628 ./ruby(rb_bug+0x28) [0x8194628] 0x80f2ef5 ./ruby [0x80f2ef5] 0xb7f8640c [0xb7f8640c] 0xb7e0f826 /lib/i686/cmov/libc.so.6(cfree+0x96) [0xb7e0f826] 0x8159c09 ./ruby(rb_fd_term+0x19) [0x8159c09] 0x80709d0 ./ruby [0x80709d0] 0x805c92c ./ruby(rb_ensure+0x9c) [0x805c92c] 0x8070bf4 ./ruby [0x8070bf4] 0x81451ad ./ruby [0x81451ad] 0x8156a06 ./ruby [0x8156a06] 0x8149c9b ./ruby [0x8149c9b] 0x81506a2 ./ruby [0x81506a2] 0x8150913 ./ruby(rb_iseq_eval_main+0x1a3) [0x8150913] 0x805ce07 ./ruby(ruby_exec_node+0x97) [0x805ce07] 0x805e596 ./ruby(ruby_run_node+0x46) [0x805e596] 0x805c100 ./ruby(main+0x60) [0x805c100] 0xb7db5455 /lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7db5455] 0x805c001 ./ruby [0x805c001] [NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html Aborted ---------------------------------------- http://redmine.ruby-lang.org