[MacRuby] #1458: Errno::EBADF occurs when use IO.pipe and IO.for_fd with MultiThread

MacRuby ruby-noreply at macosforge.org
Tue Feb 14 00:48:27 PST 2012


#1458: Errno::EBADF occurs when use IO.pipe and IO.for_fd with MultiThread
----------------------------------+-----------------------------------------
 Reporter:  watson1978@…          |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  blocker               |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------
 Test Script:
 {{{
 Thread.start do
   loop do
     begin
       r, w = IO.pipe
       w.write("a")
       r.read(10)
       GC.start
     rescue => e
       p "r = " + r.inspect
       p "w = " + w.inspect
       p e
     end
   end
 end

 loop do
   begin
     fd = IO.sysopen("/tmp/aaa.txt", "w")
     io = IO.for_fd(fd)
     io.write("aaaa")
     GC.start
   rescue => e
     p "fd = " + fd.inspect
     p "io = " + io.inspect
     raise e
   end
 end
 }}}

 Result:
 {{{
 $ macruby test_io.rb
 "r = #<IO:fd 6>"
 "w = #<IO:fd 5>"
 #<Errno::EBADF: Bad file descriptor - write() failed>
 "fd = 5"
 "io = nil"
 /Users/watson/tmp/test_io.rb:19:in `block': Bad file descriptor
 (Errno::EBADF)
         from /Users/watson/tmp/test_io.rb:16:in `<main>'
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1458>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list