Project

General

Profile

Actions

Bug #2992

closed

File operations leak file handles in Windows XP

Added by phiggins (Pete Higgins) over 14 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]
Backport:
[ruby-core:28833]

Description

=begin
Various operations on files leak file handles in Windows XP. In the two attached scripts, Task Manager will report ~30 open file handles for the ruby process at the first gets, then ~230 at the second gets.

This has only been reproducible in Windows XP. This behavior is not seen in Windows Vista or 7.

More discussion of this issue occurred on the RubyInstaller mailing list in this thread:
http://groups.google.com/group/rubyinstaller/browse_thread/thread/85ddec7241b4f0f7
=end


Files

test_md5.rb (272 Bytes) test_md5.rb phiggins (Pete Higgins), 03/21/2010 05:34 AM
test_file_read.rb (415 Bytes) test_file_read.rb phiggins (Pete Higgins), 03/21/2010 05:34 AM
Actions #1

Updated by phasis68 (Heesob Park) over 14 years ago

=begin
After some inspection, I found this leakage is not file handle but event handle.
When ReadFile fails with EOF, it returns without closing event handle.

Here is a patch for trunck verion ruby 1.9.2dev (2010-03-24 trunk 27027)

--- win32.c 2010-03-24 11:24:43.149695643 +0900
+++ win32.c.new 2010-03-24 11:26:44.522700645 +0900
@@ -4887,6 +4887,7 @@
if (!ReadFile((HANDLE)_osfhnd(fd), buf, size, &read, pol)) {
err = GetLastError();
if (err != ERROR_IO_PENDING) {

  •       if(pol) CloseHandle(ol.hEvent);
          if (err == ERROR_ACCESS_DENIED)
              errno = EBADF;
          else if (err == ERROR_BROKEN_PIPE || err == ERROR_HANDLE_EOF) {
    

=end

Actions #2

Updated by yugui (Yuki Sonoda) over 14 years ago

  • Assignee set to usa (Usaku NAKAMURA)

=begin

=end

Actions #3

Updated by yugui (Yuki Sonoda) over 14 years ago

  • Target version set to 1.9.2

=begin

=end

Actions #4

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r27042.
Pete, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0