[Mono-bugs] [Bug 78624][Nor] New - ModuleBuilder.DefineType() causes assertion failure when base type is null

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jul 14 11:24:16 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ladislav.prosek at matfyz.cz.

http://bugzilla.ximian.com/show_bug.cgi?id=78624

--- shadow/78624	2006-07-14 11:24:16.000000000 -0400
+++ shadow/78624.tmp.3917	2006-07-14 11:24:16.000000000 -0400
@@ -0,0 +1,95 @@
+Bug#: 78624
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: atsushi at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: ModuleBuilder.DefineType() causes assertion failure when base type is null
+
+When null base type is passed, ModuleBuilder.DefineType() generates an
+invalid type which causes runtime assertion failure. Build and run the
+example below:
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+public class Driver
+{
+        public static void Main ()
+        {
+                Type t = GenerateType (typeof (Test));
+                Activator.CreateInstance (t, new object [0]);
+        }
+
+        static ModuleBuilder CreateModule (string name)
+        {
+                AppDomain myDomain = System.Threading.Thread.GetDomain();
+                AssemblyName myAsmName = new AssemblyName();
+                myAsmName.Name = name;
+                AssemblyBuilder myAsmBuilder =
+myDomain.DefineDynamicAssembly (myAsmName, AssemblyBuilderAccess.RunAndSave);
+                return myAsmBuilder.DefineDynamicModule (name, name + ".dll");
+        }
+
+        static Type GenerateType (Type src)
+        {
+                ModuleBuilder mod = CreateModule ("test");
+
+                TypeBuilder tb = mod.DefineType (src.Name,
+TypeAttributes.Public, null);
+                //TypeBuilder tb = mod.DefineType (src.Name,
+TypeAttributes.Public);
+                ConstructorBuilder ctor = tb.DefineConstructor
+(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
+
+                ILGenerator gen = ctor.GetILGenerator ();
+                gen.Emit (OpCodes.Ret);
+
+                return tb.CreateType ();
+        }
+
+}
+
+public class Test
+{
+        public Echo echo = new Echo ();
+
+        public class Echo
+        {
+                public string msg = "hi there";
+        }
+}
+
+
+
+Actual Results:
+
+** ERROR **: file loader.c: line 1778 (mono_method_signature): assertion
+failed: (mono_metadata_token_table (m->token) == MONO_TABLE_METHOD)
+aborting...
+
+Expected Results:
+
+no error (on .NET).
+
+
+Additional Information:
+
+The commented line in the example code (another DefineType()) works fine,
+so the culprit is likely to be base type argument. Though I'm not sure how
+it should be conditioned to fill typeof(object) or not e.g. when the type
+is an interface.
+
+------- Additional Comments From ladislav.prosek at matfyz.cz  2006-07-14 11:24 -------
+*** Bug 78857 has been marked as a duplicate of this bug. ***


More information about the mono-bugs mailing list