Bug #2992
closedFile operations leak file handles in Windows XP
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
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
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