Issue #4531 has been updated by Motohiro KOSAKI.


Please do NOT send untested patch. :-/



% ./ruby-single-wait benchmark/bm_io_select3.rb
max fd: 100000 (results not apparent with <= 1024 max fd)
benchmark/bm_io_select3.rb:15: [BUG] Segmentation fault
ruby 1.9.3dev (2011-05-03 trunk 31412) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0007 p:---- s:0021 b:0021 l:000020 d:000020 CFUNC  :select
c:0006 p:0019 s:0016 b:0016 l:000738 d:000015 BLOCK  benchmark/bm_io_select3.rb:15
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 FINISH
c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC  :times
c:0003 p:0094 s:0009 b:0009 l:000738 d:001e00 EVAL   benchmark/bm_io_select3.rb:14
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000738 d:000738 TOP

-- Ruby level backtrace information ----------------------------------------
benchmark/bm_io_select3.rb:14:in `<main>'
benchmark/bm_io_select3.rb:14:in `times'
benchmark/bm_io_select3.rb:15:in `block in <main>'
benchmark/bm_io_select3.rb:15:in `select'

-- C level backtrace information -------------------------------------------
./ruby-single-wait() [0x528508] vm_dump.c:797
./ruby-single-wait() [0x572226] error.c:249
./ruby-single-wait(rb_bug+0xb1) [0x573631] error.c:266
./ruby-single-wait() [0x4b8420] signal.c:624
/lib64/libpthread.so.0() [0x33bf20eeb0]
/lib64/libc.so.6() [0x33bea884bb]
./ruby-single-wait(rb_thread_fd_select+0x340) [0x5307e0] thread.c:2393
./ruby-single-wait() [0x42e00c] io.c:7298
./ruby-single-wait(rb_ensure+0xab) [0x41758b] eval.c:745
./ruby-single-wait() [0x434d27] io.c:7713
./ruby-single-wait() [0x524a2d] vm_insnhelper.c:403
./ruby-single-wait() [0x519224] insns.def:1012
./ruby-single-wait() [0x51eb8e] vm.c:1163
./ruby-single-wait() [0x51f8e5] vm.c:574
./ruby-single-wait(rb_yield+0x44) [0x525504] vm.c:604
./ruby-single-wait() [0x446861] numeric.c:3225
./ruby-single-wait() [0x524a2d] vm_insnhelper.c:403
./ruby-single-wait() [0x519224] insns.def:1012
./ruby-single-wait() [0x51eb8e] vm.c:1163
./ruby-single-wait(rb_iseq_eval_main+0xbf) [0x525e3f] vm.c:1404
./ruby-single-wait() [0x4147d2] eval.c:215
./ruby-single-wait(ruby_run_node+0x34) [0x416da4] eval.c:262
./ruby-single-wait() [0x414379] main.c:38
/lib64/libc.so.6(__libc_start_main+0xfd) [0x33bea1ee5d]
./ruby-single-wait() [0x414269]

-- Other runtime information -----------------------------------------------

* Loaded script: benchmark/bm_io_select3.rb

* Loaded features:

    0 enumerator.so
    1 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
    2 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
    3 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems/defaults.rb
    4 /home/kosaki/ruby/lib/ruby/1.9.1/tsort.rb
    5 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems/dependency_list.rb
    6 /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb
    7 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems/exceptions.rb
    8 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems/custom_require.rb
    9 /home/kosaki/ruby/lib/ruby/1.9.1/rubygems.rb

* Process memory map:

00400000-00625000 r-xp 00000000 fd:03 2626950                            /home/kosaki/linux/ruby/ruby-single-wait
00824000-00827000 rw-p 00224000 fd:03 2626950                            /home/kosaki/linux/ruby/ruby-single-wait
00827000-0083f000 rw-p 00000000 00:00 0
014b6000-032bf000 rw-p 00000000 00:00 0                                  [heap]
33be200000-33be21f000 r-xp 00000000 fd:00 4980738                        /lib64/ld-2.13.so
33be41e000-33be41f000 r--p 0001e000 fd:00 4980738                        /lib64/ld-2.13.so
33be41f000-33be420000 rw-p 0001f000 fd:00 4980738                        /lib64/ld-2.13.so
33be420000-33be421000 rw-p 00000000 00:00 0
33bea00000-33beb91000 r-xp 00000000 fd:00 4980744                        /lib64/libc-2.13.so
33beb91000-33bed91000 ---p 00191000 fd:00 4980744                        /lib64/libc-2.13.so
33bed91000-33bed95000 r--p 00191000 fd:00 4980744                        /lib64/libc-2.13.so
33bed95000-33bed96000 rw-p 00195000 fd:00 4980744                        /lib64/libc-2.13.so
33bed96000-33bed9c000 rw-p 00000000 00:00 0
33bee00000-33bee02000 r-xp 00000000 fd:00 4980748                        /lib64/libdl-2.13.so
33bee02000-33bf002000 ---p 00002000 fd:00 4980748                        /lib64/libdl-2.13.so
33bf002000-33bf003000 r--p 00002000 fd:00 4980748                        /lib64/libdl-2.13.so
33bf003000-33bf004000 rw-p 00003000 fd:00 4980748                        /lib64/libdl-2.13.so
33bf200000-33bf217000 r-xp 00000000 fd:00 4980758                        /lib64/libpthread-2.13.so
33bf217000-33bf416000 ---p 00017000 fd:00 4980758                        /lib64/libpthread-2.13.so
33bf416000-33bf417000 r--p 00016000 fd:00 4980758                        /lib64/libpthread-2.13.so
33bf417000-33bf418000 rw-p 00017000 fd:00 4980758                        /lib64/libpthread-2.13.so
33bf418000-33bf41c000 rw-p 00000000 00:00 0
33bf600000-33bf684000 r-xp 00000000 fd:00 4980756                        /lib64/libm-2.13.so
33bf684000-33bf883000 ---p 00084000 fd:00 4980756                        /lib64/libm-2.13.so
33bf883000-33bf884000 r--p 00083000 fd:00 4980756                        /lib64/libm-2.13.so
33bf884000-33bf885000 rw-p 00084000 fd:00 4980756                        /lib64/libm-2.13.so
33bfa00000-33bfa15000 r-xp 00000000 fd:00 4980798                        /lib64/libgcc_s-4.5.1-20100924.so.1
33bfa15000-33bfc14000 ---p 00015000 fd:00 4980798                        /lib64/libgcc_s-4.5.1-20100924.so.1
33bfc14000-33bfc15000 rw-p 00014000 fd:00 4980798                        /lib64/libgcc_s-4.5.1-20100924.so.1
33c0200000-33c0207000 r-xp 00000000 fd:00 4980764                        /lib64/librt-2.13.so
33c0207000-33c0406000 ---p 00007000 fd:00 4980764                        /lib64/librt-2.13.so
33c0406000-33c0407000 r--p 00006000 fd:00 4980764                        /lib64/librt-2.13.so
33c0407000-33c0408000 rw-p 00007000 fd:00 4980764                        /lib64/librt-2.13.so
33caa00000-33caa07000 r-xp 00000000 fd:00 4980814                        /lib64/libcrypt-2.13.so
33caa07000-33cac07000 ---p 00007000 fd:00 4980814                        /lib64/libcrypt-2.13.so
33cac07000-33cac08000 r--p 00007000 fd:00 4980814                        /lib64/libcrypt-2.13.so
33cac08000-33cac09000 rw-p 00008000 fd:00 4980814                        /lib64/libcrypt-2.13.so
33cac09000-33cac37000 rw-p 00000000 00:00 0
33cae00000-33cae5d000 r-xp 00000000 fd:00 4980811                        /lib64/libfreebl3.so
33cae5d000-33cb05c000 ---p 0005d000 fd:00 4980811                        /lib64/libfreebl3.so
33cb05c000-33cb05e000 rw-p 0005c000 fd:00 4980811                        /lib64/libfreebl3.so
33cb05e000-33cb062000 rw-p 00000000 00:00 0
7f6892403000-7f68924e3000 rw-p 00000000 00:00 0
7f6892509000-7f689250b000 r-xp 00000000 fd:03 1725292                    /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7f689250b000-7f689270a000 ---p 00002000 fd:03 1725292                    /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7f689270a000-7f689270b000 rw-p 00001000 fd:03 1725292                    /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7f689270b000-7f689270d000 r-xp 00000000 fd:03 1725319                    /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7f689270d000-7f689290c000 ---p 00002000 fd:03 1725319                    /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7f689290c000-7f689290d000 rw-p 00001000 fd:03 1725319                    /home/kosaki/ruby/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7f689290d000-7f689290e000 ---p 00000000 00:00 0
7f689290e000-7f6892a12000 rw-p 00000000 00:00 0
7f6892a12000-7f68988a2000 r--p 00000000 fd:00 277164                     /usr/lib/locale/locale-archive
7f68988a2000-7f68988a7000 rw-p 00000000 00:00 0
7f68988c1000-7f68988c3000 rw-p 00000000 00:00 0
7fffc64c8000-7fffc64e9000 rw-p 00000000 00:00 0                          [stack]
7fffc652e000-7fffc652f000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]


[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

zsh: abort (core dumped)  ./ruby-single-wait benchmark/bm_io_select3.rb
----------------------------------------
Feature #4531: [PATCH 0/7] use poll() instead of select() in certain cases
http://redmine.ruby-lang.org/issues/4531

Author: Eric Wong
Status: Open
Priority: Low
Assignee: Motohiro KOSAKI
Category: core
Target version: 1.9.x


=begin
ref: [ruby-core:35527]

This adds a new C API function with the following prototype:

   rb_io_poll_fd(int fd, short events, int timeout);

It is emulated using select() for platforms that we do not support
poll() for.  It is much easier to use than rb_thread_select() and
rb_thread_fd_select() for the common case in C extensions[1].

For Linux (and eventually any other platforms where poll() works for all
select()-able files), we actually implement rb_io_poll_fd() using the
poll() system call which means it is faster for high numbered file
descriptors and does not put malloc pressure on the garbage collector.

Lastly, since IO.select() is commonly used with a single IO object
in my experience, we will try to use rb_io_poll_fd() in that case.

There is also a new testcase for io/wait since I needed to verify my
changes to ext/io/wait.c were correct.

No failures were introduced to test-all and test-rubyspec targets with
either the select() or poll()-based implementation of rb_io_poll_fd()
on my platform (Linux x86_64)

[1] see patches for changes I made in ext/socket/init.c, ext/io/wait.c,
    and ext/readline/readline.c:
$ git diff --stat origin/trunk -- ext
 ext/io/wait/wait.c      |   34 +++-------------------
 ext/readline/readline.c |    6 +---
 ext/socket/init.c       |   72 ++++++++---------------------------------------
 3 files changed, 18 insertions(+), 94 deletions(-)


=end



-- 
http://redmine.ruby-lang.org