From: akr@... Date: 2019-01-10T07:10:29+00:00 Subject: [ruby-core:90972] [Ruby trunk Feature#2250][Rejected] IO::for_fd() objects' finalization dangerously closes underlying fds Issue #2250 has been updated by akr (Akira Tanaka). Status changed from Open to Rejected We discussed this issue today's Ruby developer meeting. Our conclusion is that changing the default behavior of IO.for_fd is too incompatible. It changes good working program to FD-leaking program. It is another big issue, especially problematic for long-running server and very very difficult to debug. ---------------------------------------- Feature #2250: IO::for_fd() objects' finalization dangerously closes underlying fds https://bugs.ruby-lang.org/issues/2250#change-76183 * Author: pilcrow (Mike Pomraning) * Status: Rejected * Priority: Normal * Assignee: Eregon (Benoit Daloze) * Target version: ---------------------------------------- =begin 1. Expected behavior: An IO object created by IO::for_fd(a_socket_fd) should *not* call close(2) on its underlying fd upon finalization. The object did not allocate the fd, and so cannot safely nor politely close it. 2. Observed behavior: Instead, an IO object created by IO::for_fd(a_socket_fd) will attempt to close(2) its underlying socket fd upon finalization. 3. How to reproduce: The attached script and trivial extension module demonstrate that an IO::for_fd()-created object may secretly close(2) the fd behind an innocent File.new(...) object, causing operations on that File object to fail for no reason apparent in (nor knowable to) the ruby code. On 32-bit Linux under ruby-1.9 (or 1.8. for that matter), it produces: $ ruby io-finalize.rb #