From: Tanaka Akira Date: 2010-02-24T23:12:41+09:00 Subject: [ruby-core:28327] Re: [Bug:trunk] add explicit constraints for WONTFIX IO bug 2010/2/22 Yusuke ENDOH : > > In short, it means "IO#dup should not be used" and "IO that was once > passed to IO#reopen should be just closed." > "bezarre behavior" does not mean undefined behavior (such as SEGV), > but means wrong order of reading and writing, wrong value from > IO#pos, etc. (see Appendix) > > These behaviors are caused by bug of core's wrong buffering handing. I think it is difficult to fix. The "bizarre" behavior can be occur without IO#dup and IO#reopen. By IO.new: % ./ruby -e ' f1 = File.new("foo.txt") f2 = IO.new(f1.fileno) p f1.gets p f2.gets ' "A\n" nil file descriptors may be shared at outside of ruby: % ./ruby -e ' f1 = IO.new(3) f2 = IO.new(4) p f1.gets p f2.gets ' 3< foo.txt 4<&3 "A\n" nil file descriptors may be shared between processes: % ( ./ruby -e 'p STDIN.gets'; ./ruby -e 'p STDIN.gets' ) < foo.txt "A\n" nil This behavior is inherent result of buffering. I think we should live with this behavior because buffering is important for performance. -- Tanaka Akira