[Mono-bugs] [Bug 325988] New: Mono leaks file handles

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Sep 18 08:50:00 EDT 2007


https://bugzilla.novell.com/show_bug.cgi?id=325988

           Summary: Mono leaks file handles
           Product: Mono: Runtime
           Version: unspecified
          Platform: Other
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: msafar at novell.com
         QAContact: mono-bugs at ximian.com
          Found By: ---


Compile & Run following program.

Note: you have to create temp file or change temp location.

using System;
using System.Reflection;
using System.IO;
using System.Threading;
using System.Reflection.Emit;

public class C
{
        public static void Main ()
        {
                const string temp_folder = @"temp";
                const int maxfiles = 2000;
                for (int i = 1; i < maxfiles; ++i) {
                        string file_name = String.Format ("gtest-{0:000}.exe",
i);
                        string full_path = Path.Combine (temp_folder,
file_name);
                        if (!File.Exists (full_path)) {
                                AppDomain currentDomain = Thread.GetDomain ();
                                AssemblyName myAssemblyName = new AssemblyName
(file_name);
                                AssemblyBuilder builder =
                                        currentDomain.DefineDynamicAssembly (
                                        myAssemblyName,
                                        AssemblyBuilderAccess.RunAndSave,
temp_folder);
                                builder.Save (file_name);
                        }

                        Assembly.LoadFile (full_path);
                }
        }
}

Expected:

No error.

Actual:

Program terminates with

Unhandled Exception: System.IO.IOException: Too many open files
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions
options) [0x00000] 
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean isAsync, Boolean anonymous)
[0x00000] 
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess
access) [0x00000] 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor
(string,System.IO.FileMode,System.IO.FileAccess)
  at System.Reflection.Emit.ModuleBuilder.Save () [0x00000] 
  at System.Reflection.Emit.AssemblyBuilder.Save (System.String
assemblyFileName, PortableExecutableKinds portableExecutableKind,
ImageFileMachine imageFileMachine) [0x00000] 
  at System.Reflection.Emit.AssemblyBuilder.Save (System.String
assemblyFileName) [0x00000] 
  at C.Main () [0x00000]


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list