Issue #6228 has been updated by h.shirosaki (Hiroshi Shirosaki).


I tried to create simplified test case of this issue.

> cat gc_io_test.rb
f = open("test_file", "w")
p f.fileno
IO.for_fd(f.fileno).close

f = open("test_file", "w")
p f.fileno

GC.start # trigger GC

begin
  f.close # => raise Errno::EBADF
rescue
  p $!
end

File.unlink("test_file")

> ~/ruby-trunk/bin/ruby -v gc_io_test.rb
ruby 2.0.0dev (2012-04-17 trunk 35363) [x86_64-darwin11.3.0]
5
5
#<Errno::EBADF: Bad file descriptor - test_file>
----------------------------------------
Bug #6228: [mingw] Errno::EBADF in ruby/test_io.rb on ruby_1_9_3
https://bugs.ruby-lang.org/issues/6228#change-25970

Author: jonforums (Jon Forums)
Status: Assigned
Priority: Normal
Assignee: luislavena (Luis Lavena)
Category: test
Target version: 1.9.3
ruby -v: ruby 1.9.3p172 (2012-03-30 revision 35179) [i386-mingw32]


On Win7 32bit built with MinGW 4.6.2 using the RubyInstaller build recipes, I get the following test error:


sh-3.1$ ruby --version
ruby 1.9.3p172 (2012-03-30 revision 35179) [i386-mingw32]

sh-3.1$ make test-all TESTS='openssl fiddle psych zlib io json mkmf pathname stringio erb 
fileutils ruby/test_io.rb ruby/test_io_m17n.rb ruby/test_file.rb'

  7) Error:
test_lines(TestIO):
Errno::EBADF: Bad file descriptor
    c:/Users/Jon/Documents/RubyDev/ruby-git/test/ruby/test_io.rb:33:in `close'
    c:/Users/Jon/Documents/RubyDev/ruby-git/test/ruby/test_io.rb:33:in `rescue in block in pipe'
    c:/Users/Jon/Documents/RubyDev/ruby-git/test/ruby/test_io.rb:30:in `block in pipe'


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