From: "h.shirosaki (Hiroshi Shirosaki)" Date: 2012-04-17T07:23:13+09:00 Subject: [ruby-core:44398] [ruby-trunk - Bug #6228] [mingw] Errno::EBADF in ruby/test_io.rb on ruby_1_9_3 Issue #6228 has been updated by h.shirosaki (Hiroshi Shirosaki). This issue seems to be related to GC finalizer. GC is triggered just before Errno::EBADF occurs, and finalizer closes the fd of make_tempfile. Errno::EBADF is raised for trying to close again the closed fd of make_tempfile. This seems due to `test_flush_in_finalizer1`. 500.times { f = File.open(path, "w") fds << f.fileno f.print "hoge" } `f` is not closed. When GC sweeps `f`, the fd associated with `f` seems to be closed. `fds` contains `3`. And make_tempfile in `test_invalid_advise` creates fd of 3. I confirmed the error disappeared with the following patch. -DFD_SETSEZE=32767 and ruby 1.9.3p184 (2012-04-15 revision 35335) [i386-mingw32] on Windows 7. diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index edf449d..70ca240 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1800,6 +1800,7 @@ End end ensure fds.each {|fd| IO.for_fd(fd).close rescue next} + GC.start end def test_flush_in_finalizer2 ---------------------------------------- Bug #6228: [mingw] Errno::EBADF in ruby/test_io.rb on ruby_1_9_3 https://bugs.ruby-lang.org/issues/6228#change-25945 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/