From: Luis Lavena Date: 2012-05-14T01:31:22+09:00 Subject: [ruby-core:45021] Re: [ruby-trunk - Bug #6228] [mingw] Errno::EBADF in ruby/test_io.rb on ruby_1_9_3 --bcaec502d770dc83b304bfed7f1c Content-Type: text/plain; charset=ISO-8859-1 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/ > > --bcaec502d770dc83b304bfed7f1c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Hi Tomoyuki,

Please revert my change. As commented before, was unable to use your sug= gested patch since the invalid file descriptor error 'moved' to a d= ifferent 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 (Tomoy= uki Chikanaga)" <nagachika= 00@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 obj= ects 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.

=A0io =3D open("..")
=A0fd =3D io.fileno
=A0io =3D nil
=A0IO.for_fd(fd).close =A0 =A0# <- at this moment, io (if not GC'ed = yet) has invalid fd,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0# because it's already = closed by IO.for_fd(fd).close
=A0new_io =3D open("...") =A0 # new_io might have same fd of io, = because file descriptor can be recycled.
=A0... =A0 =A0# =3D> io is GC'ed and finalized here. Now new_io has = closed fd!
=A0new_io.gets =A0 # =3D> raised Errno::EBADF

test_flush_in_finalizer1 is test for finalizer of IO (see #3910) and GC.dis= able 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=3D'openssl fiddle psych zlib io json mkmf p= athname stringio erb
fileutils ruby/test_io.rb ruby/test_io_m17n.rb ruby/test_file.rb'

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


--
http://bugs.ruby-l= ang.org/

--bcaec502d770dc83b304bfed7f1c--