[Mono-bugs] [Bug 70838][Min] New - System.Type IsAssignableFrom crashes when assembly is builded for Save

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 28 Dec 2004 05:49:49 -0500 (EST)


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 nazgul@omega.pl.

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

--- shadow/70838	2004-12-28 05:49:49.000000000 -0500
+++ shadow/70838.tmp.3440	2004-12-28 05:49:49.000000000 -0500
@@ -0,0 +1,82 @@
+Bug#: 70838
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: Mandrake Linux 10.0, mono 1.1.2, mono 1.0.4
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: nazgul@omega.pl               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.Type IsAssignableFrom crashes when assembly is builded for Save
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+When building assembly with AssemblyBuilderAccess.Save, IsAssignableFrom
+method of System.Type do not work as expected. It crashes when run for
+typeof (System.IComparable) against currently builded type inheriting from
+System.IComparable.
+
+Steps to reproduce the problem:
+1. Compile following program:
+
+using System;
+using System.Reflection;
+
+using System.Reflection.Emit;
+class X {
+
+static void Main ()
+{
+AssemblyName asmname = new AssemblyName();
+asmname.Name = "assemfilename.exe";
+AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().
+DefineDynamicAssembly(asmname, AssemblyBuilderAccess.Save);
+ModuleBuilder modbuild = asmbuild.DefineDynamicModule("modulename",
+"assemfilename.exe");
+
+Type icomparable = typeof (System.IComparable);
+
+TypeBuilder typebuild1 = modbuild.DefineType("typename",
+TypeAttributes.Public, null, new Type[] { icomparable });
+
+System.Console.WriteLine (icomparable.IsAssignableFrom (typebuild1));
+
+typebuild1.CreateType();
+
+asmbuild.Save("assemfilename.exe");
+
+}
+}
+
+
+2. Run it.
+
+
+Actual Results:
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+in <0xc7064e34> (wrapper managed-to-native)
+System.Type:type_is_assignable_from (System.Type,System.Type)
+in <0x00004> (wrapper managed-to-native)
+System.Type:type_is_assignable_from (System.Type,System.Type)
+in <0x0003e> System.Type:IsAssignableFrom (System.Type)
+in <0x000e3> X:Main ()
+
+
+Expected Results:
+True
+
+How often does this happen? 
+With .Save attribute it seems to happen always, but with RunAndSave
+sometimes goes ok - in the wider context of Nemerle compiler it runs ok
+with RunAndSave, but fails with Save.
+
+Additional Information: