Bug 40643 - Process leaking handles leads to "too many open files"
Summary: Process leaking handles leads to "too many open files"
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: Macintosh Mac OS
: High major
Target Milestone: Untriaged
Assignee: Ludovic Henry
URL:
Depends on:
Blocks:
 
Reported: 2016-04-22 15:46 UTC by Mike Voorhees
Modified: 2016-06-23 14:42 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Compile and run to reproduce (1.52 KB, text/plain)
2016-04-22 15:46 UTC, Mike Voorhees
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Mike Voorhees 2016-04-22 15:46:03 UTC
Created attachment 15819 [details]
Compile and run to reproduce

When running processes with output redirected, you will eventually run into the following exception :

Unhandled Exception:
System.IO.IOException: Too many open files
  at System.Diagnostics.Process.CreatePipe (System.IntPtr& read, System.IntPtr& write, System.Boolean writeDirection) <0x102c0af70 + 0x001f0> in <filename unknown>:0 
  at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) <0x102c09e40 + 0x00397> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: Too many open files
  at System.Diagnostics.Process.CreatePipe (System.IntPtr& read, System.IntPtr& write, System.Boolean writeDirection) <0x102c0af70 + 0x001f0> in <filename unknown>:0 
  at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) <0x102c09e40 + 0x00397> in <filename unknown>:0


On my system, with the repro case attached, it took until run 592 to happen.

With mono 3.12.1 and 4.2.2 this test case passes.

It looks like this was introduced during some refactoring to the Process class.  Maybe the FIXME's in https://github.com/mono/mono/blob/master/mcs/class/System/System.Diagnostics/Process.cs are related.
Comment 1 Ludovic Henry 2016-04-24 18:01:57 UTC
Hi Mike,

Thank you for the report. You are right, the bug comes from one of the FIXME in https://github.com/mono/mono/blob/master/mcs/class/System/System.Diagnostics/Process.cs. I am currently trying to figure out why we need that in the first place.

Thank you,
Ludovic
Comment 2 Ludovic Henry 2016-04-24 20:16:53 UTC
This is fixed with https://github.com/mono/mono/pull/2946
Comment 3 Mike Voorhees 2016-04-25 11:53:05 UTC
Thanks!
Comment 4 eric 2016-06-23 14:42:49 UTC
What release was this pushed to, I don't see this in the latest release.  Also if I look at the modified files from this PR, I don't see it in the master branch anymore.