[Mono-bugs] [Bug 79972][Nor] New - gmcs crash when pass an generic anonymous method to a constructor
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sun Nov 19 02:49:31 EST 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 redforks at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=79972
--- shadow/79972 2006-11-19 02:49:31.000000000 -0500
+++ shadow/79972.tmp.4260 2006-11-19 02:49:31.000000000 -0500
@@ -0,0 +1,104 @@
+Bug#: 79972
+Product: Mono: Compilers
+Version: unspecified
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com
+ReportedBy: redforks at gmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: gmcs crash when pass an generic anonymous method to a constructor
+
+Pass an generic anonymous method to a constructor, like this:
+
+
+delegate void TestFunc<T>(T val);
+
+class A
+{
+ public A(TestFunc<int> func) { }
+}
+
+class TestClass
+{
+ readonly A a = new A(delegate(int a) { });
+ static void Func<T>(TestFunc<T> func) { }
+}
+
+
+gmcs will crash:
+
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+ at Mono.CSharp.AnonymousMethod.DoCreateMethodHost
+(Mono.CSharp.EmitContext ec) [0x00093] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/anonymous.cs:1363
+ at Mono.CSharp.AnonymousContainer.Resolve (Mono.CSharp.EmitContext ec)
+[0x0012a] in /tmp/scratch/BUILD/mono-1.2/mcs/mcs/anonymous.cs:1246
+ at Mono.CSharp.AnonymousMethod.Resolve (Mono.CSharp.EmitContext ec)
+[0x00000] in /tmp/scratch/BUILD/mono-1.2/mcs/mcs/anonymous.cs:1379
+ at Mono.CSharp.AnonymousMethodExpression.Compatible
+(Mono.CSharp.EmitContext ec, System.Type delegate_type) [0x00321] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/anonymous.cs:1111
+ at Mono.CSharp.Convert.ImplicitConversionStandard
+(Mono.CSharp.EmitContext ec, Mono.CSharp.Expression expr, System.Type
+target_type, Location loc) [0x001b2] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/convert.cs:1342
+ at Mono.CSharp.Convert.ImplicitConversion (Mono.CSharp.EmitContext ec,
+Mono.CSharp.Expression expr, System.Type target_type, Location loc)
+[0x00012] in /tmp/scratch/BUILD/mono-1.2/mcs/mcs/convert.cs:1233
+ at Mono.CSharp.Invocation.VerifyArgumentsCompat (Mono.CSharp.EmitContext
+ec, System.Collections.ArrayList Arguments, Int32 arg_count,
+System.Reflection.MethodBase method, Boolean chose_params_expanded,
+System.Type delegate_type, Boolean may_fail, Location loc) [0x000b1] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/expression.cs:4895
+ at Mono.CSharp.Invocation.OverloadResolve (Mono.CSharp.EmitContext ec,
+Mono.CSharp.MethodGroupExpr me, System.Collections.ArrayList Arguments,
+Boolean may_fail, Location loc) [0x00609] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/expression.cs:4802
+ at Mono.CSharp.New.DoResolve (Mono.CSharp.EmitContext ec) [0x0033c] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/expression.cs:5741
+ at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec,
+ResolveFlags flags) [0x00067] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/ecore.cs:415
+ at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000]
+in /tmp/scratch/BUILD/mono-1.2/mcs/mcs/ecore.cs:442
+ at Mono.CSharp.FieldBase.ResolveInitializer () [0x00022] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/class.cs:5613
+ at Mono.CSharp.ClassOrStruct.DefineFieldInitializers () [0x00025] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/class.cs:2793
+ at Mono.CSharp.ClassOrStruct.Define () [0x00000] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/class.cs:2834
+ at Mono.CSharp.RootContext.DefineTypes () [0x000e2] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/rootcontext.cs:585
+ at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x0053e] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/driver.cs:1675
+ at Mono.CSharp.Driver.Main (System.String[] args) [0x0001f] in
+/tmp/scratch/BUILD/mono-1.2/mcs/mcs/driver.cs:292
+
+And I made a patch:
+
+Index: anonymous.cs
+===================================================================
+--- anonymous.cs (revision 68052)
++++ anonymous.cs (working copy)
+@@ -1361,7 +1361,7 @@
+ member_name = new MemberName (name, args,
+Location);
+
+ generic_method = new GenericMethod (
+- RootScope.NamespaceEntry,
+RootScope, member_name,
++ RootScope != null ?
+RootScope.NamespaceEntry : null, RootScope, member_name,
+ new TypeExpression (ReturnType,
+Location), Parameters);
+
+ generic_method.SetParameterInfo (null);
More information about the mono-bugs
mailing list