Bug 315977 (MONO65576) - [PATCH] Calling GetTypes on a Dynamically generated assembly throws an OOM Exception
Summary: [PATCH] Calling GetTypes on a Dynamically generated assembly throws an OOM Ex...
Status: RESOLVED FIXED
Alias: MONO65576
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Major
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-09 04:14 UTC by Geoff Norton
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
proposed patch (3.55 KB, patch)
2004-09-09 05:57 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:53:04 UTC


---- Reported by grompf@sublimeintervention.com 2004-09-08 21:14:23 MST ----

The following code runs on MS.NET v1.1 but throws and OutOfMemoryException on mono:

using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Threading;

namespace Apple.Foundation {
        public class Test {
                static Assembly generated = null;
                static Assembly GenerateAssembly() {
                        AssemblyName an = new AssemblyName();
                        an.Name = "Test";
                        AssemblyBuilder builder = 
AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Run);
                        ModuleBuilder module = builder.DefineDynamicModule(an.Name);
                        TypeBuilder typebuilder = module.DefineType("Generator", 
TypeAttributes.Public);
                        typebuilder.CreateType();
                        module.CreateGlobalFunctions();
                        return module.Assembly;
                }
                static Assembly TypeResolve(object sender, ResolveEventArgs args)
                {
                        Console.WriteLine ("Returning resolver...");
                        if (generated == null)
                                generated = GenerateAssembly();
                        // Mono OOM here
                        foreach (Type t in generated.GetTypes())
                                Console.WriteLine("TYPE={0}", t);
                        return generated;
                }
                static void Main (string[] args) {
                        AppDomain.CurrentDomain.TypeResolve += new ResolveEventHandler 
(TypeResolve);
                        Type t = System.Type.GetType("Generator");
                }
        }
}



---- Additional Comments From grompf@sublimeintervention.com 2004-09-08 22:57:26 MST ----

Created an attachment (id=166746)
proposed patch




---- Additional Comments From grompf@sublimeintervention.com 2004-09-08 22:57:56 MST ----

The attached patch causes mono to act the same as MS.NET for calling GetTypes on 
dynamically emitted assemblies.





---- Additional Comments From vargaz@freemail.hu 2004-09-09 09:00:56 MST ----

This is ok to check in, but please fix the formatting (space between
if and (, etc).



---- Additional Comments From grompf@sublimeintervention.com 2004-09-09 12:06:01 MST ----

spacing fixed and applied to head

Imported an attachment (id=166746)

Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>OSX 10.3.4</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".