Hi Tomoyuki,

Please revert my change. As commented before, was unable to use your
suggested patch since the invalid file descriptor error 'moved' to a
different test.

I was unable to replicate the error from chkbuild.

Please revert and commit your change, will verify again later today.

Thank you.

Sorry for top posting. Sent from mobile.
On May 13, 2012 11:32 AM, "nagachika (Tomoyuki Chikanaga)" <
nagachika00 / gmail.com> wrote:

>
> Issue #6228 has been updated by nagachika (Tomoyuki Chikanaga).
>
>
> Hi Luis,
>
> Sorry for a lack of enough explanations about my patch.
>
> The ensure clause of test_flush_in_finalizer1 seems to try close all IO
> objects opened above and not GC'ed & finalized using IO.for_fd. But it's
> wrong usage of IO.for_fd. The scenario is as follows.
>
>  io = open("..")
>  fd = io.fileno
>  io = nil
>  IO.for_fd(fd).close    # <- at this moment, io (if not GC'ed yet) has
> invalid fd,
>                        # because it's already closed by IO.for_fd(fd).close
>  new_io = open("...")   # new_io might have same fd of io, because file
> descriptor can be recycled.
>  ...    # => io is GC'ed and finalized here. Now new_io has closed fd!
>  new_io.gets   # => raised Errno::EBADF
>
> test_flush_in_finalizer1 is test for finalizer of IO (see #3910) and
> GC.disable breaks it's intent.
> I'm sorry, but I'd like to revert r35631.
> And I'll commit my patch. Please check it.
> ----------------------------------------
> Bug #6228: [mingw] Errno::EBADF in ruby/test_io.rb on ruby_1_9_3
> https://bugs.ruby-lang.org/issues/6228#change-26601
>
> 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/
>
>