Skip to content

Commit

Permalink
[mtouch] Add workarounds for file descriptor leak in System.Diagnosti…
Browse files Browse the repository at this point in the history
…cs.Process. (#1137)

This is a backport of these commits from master: 4d06d05, 1fdd17e and 39ec76e.

It fixes this mtouch test:

    1) Test Error : MTouchTests.MTouch.ScriptedTests

        [...]
        error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
        System.IO.IOException: Too many open files
          at System.Diagnostics.Process.CreatePipe (System.IntPtr& read, System.IntPtr& write, System.Boolean writeDirection) [0x00094] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Diagnostics/Process.cs:659
          at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0012c] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Diagnostics/Process.cs:716
  • Loading branch information
rolfbjarne authored and spouliot committed Nov 8, 2016
1 parent 7063960 commit 350be88
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/mtouch/RegistrarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,8 @@ static void Compile (string filename, MTouch.Profile profile = MTouch.Profile.Cl
};
p.WaitForExit ();

GC.Collect (); // Workaround for: https://bugzilla.xamarin.com/show_bug.cgi?id=43462#c14

Console.WriteLine (output);

if (p.ExitCode != 0)
Expand Down
2 changes: 2 additions & 0 deletions tools/common/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public static int RunCommand (string path, string args, string[] env = null, Str
stderr_completed.WaitOne (TimeSpan.FromSeconds (1));
stdout_completed.WaitOne (TimeSpan.FromSeconds (1));

GC.Collect (); // Workaround for: https://bugzilla.xamarin.com/show_bug.cgi?id=43462#c14

if (p.ExitCode != 0) {
// note: this repeat the failing command line. However we can't avoid this since we're often
// running commands in parallel (so the last one printed might not be the one failing)
Expand Down
2 changes: 2 additions & 0 deletions tools/mtouch/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,8 @@ protected int Start ()
stderr_completed.WaitOne (TimeSpan.FromSeconds (1));
stdout_completed.WaitOne (TimeSpan.FromSeconds (1));

GC.Collect (); // Workaround for: https://bugzilla.xamarin.com/show_bug.cgi?id=43462#c14

if (p.ExitCode != 0)
return p.ExitCode;

Expand Down
3 changes: 3 additions & 0 deletions tools/mtouch/mtouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,9 @@ static int CallMlaunch ()
RedirectStream (p.StandardError, new StreamWriter (Console.OpenStandardError ()));

p.WaitForExit ();

GC.Collect (); // Workaround for: https://bugzilla.xamarin.com/show_bug.cgi?id=43462#c14

return p.ExitCode;
}
}
Expand Down

0 comments on commit 350be88

Please sign in to comment.