[MacRuby] #1402: Errno::EBADF occurs when repeats reading/writing the file.
#1402: Errno::EBADF occurs when repeats reading/writing the file. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Using IO's object which is created by IO.new, [[BR]] Errno::EBADF occurs when repeats reading/writing the file. Test Script: {{{ #!ruby path = "/tmp/test.txt" def new_io(name, mode) fd = IO.sysopen(name, mode) IO.new(fd, mode) end 100.times do io = new_io(path, "w") io.puts "Hello, world" io.close io = new_io(path, "r") io.read io.close end }}} Result: {{{ $ macruby t.rb /Users/watson/tmp/t.rb:5:in `new_io': Bad file descriptor (Errno::EBADF) from /Users/watson/tmp/t.rb:10:in `block' from /Users/watson/tmp/t.rb:9:in `<main>' }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1402> MacRuby <http://macruby.org/>
#1402: Errno::EBADF occurs when repeats reading/writing the file. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by watson1978@…): IO#sysopen creates the IO's object, and returns file descriptor from its object. [[BR]] When invoked GC finalizer for its object, it seems to occurs Errno::EBADF. 1. IO#sysopen creates IO's object, returns file descriptor. 2. IO.new creates IO's object from file descriptor. 3. GC finalizer run for object of IO#sysopen - invoke rb_objc_io_finalize - -> close file descriptor by rb_io_close - -> same descriptor number is used by IO.new's object. 4. IO#read -> Errno::EBADF I think that should not create an IO's object in IO#sysopen. -- Ticket URL: <http://www.macruby.org/trac/ticket/1402#comment:1> MacRuby <http://macruby.org/>
#1402: Errno::EBADF occurs when repeats reading/writing the file. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.11 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Changes (by watson1978@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.11 Comment: Fixed with https://github.com/MacRuby/MacRuby/commit/5f32d0b9aa317448e341fb22184a78edf5... -- Ticket URL: <http://www.macruby.org/trac/ticket/1402#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby