[Mono-bugs] [Bug 36191][Wis] New - Invoking a "uninvokable" method causes an assertion failure
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
30 Dec 2002 23:33:48 -0000
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 jonpryor@vt.edu.
http://bugzilla.ximian.com/show_bug.cgi?id=36191
--- shadow/36191 Mon Dec 30 18:33:48 2002
+++ shadow/36191.tmp.22654 Mon Dec 30 18:33:48 2002
@@ -0,0 +1,94 @@
+Bug#: 36191
+Product: Mono/Runtime
+Version: unspecified
+OS: other
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: jonpryor@vt.edu
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Invoking a "uninvokable" method causes an assertion failure
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+Certain methods cannot be invoked, such as unimplemented interface members
+and abstract methods. The compiler helps ensure that this doesn't happen,
+but using System.Reflection.MethodInfo.Invoke can bypass the compilers
+assistance.
+
+Actually invoking such a method shouldn't generate an assertion failure, it
+should generate an exception.
+
+Consider the following source code:
+
+ // Mono Assert Failed: test case
+ //
+
+ using System;
+ using System.Reflection;
+
+ public interface IFoo
+ {
+ void Run ();
+ }
+
+ public abstract class Foo
+ {
+ public abstract void Run ();
+ }
+
+ public class R {
+ public static void Main () {
+ Type t = typeof (IFoo);
+ Type t2 = typeof (Foo);
+ InvokeMethods (t);
+ InvokeMethods (t2);
+ }
+
+ private static void InvokeMethods (Type t)
+ {
+ foreach (MethodInfo mi in t.GetMethods()) {
+ Console.WriteLine ("Method: {0}", mi.Name);
+ string s = null;
+ try {
+ object r = mi.Invoke (null, null);
+ s = r.ToString ();
+ }
+ catch (Exception e) {
+ s = string.Format ("Exception caught: {0}", e.ToString());
+ }
+ Console.WriteLine ("Value: {0}", s);
+ Console.WriteLine ("-");
+ }
+ }
+ }
+
+When run under Mono, I get the following error message:
+
+ Method: Run
+
+ ** ERROR **: file jit.c: line 3640 (mono_cfg_new): assertion
+failed: (((MonoMethodNormal *)method)->header)
+ aborting...
+ Aborted
+
+When run under .NET, System.Reflection.TargetException's are generated
+(with full stack traces, so a lot of output is produced).
+
+How often does this happen? Always.
+
+Additional Information:
+
+This was done with the CVS source from December 22, so this may not be up
+to date. However, the assertion is emitted from jit.c and I haven't seen
+any CVS commits to that file since then, so it's fairly probable that this
+issue is still present.