[Mono-bugs] [Bug 60485][Blo] New - mono_marshal_get_runtime_invoke() cache lookup bug

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 21 Jun 2004 02:18:06 -0400 (EDT)


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 martin@ximian.com.

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

--- shadow/60485	2004-06-21 02:18:06.000000000 -0400
+++ shadow/60485.tmp.32402	2004-06-21 02:18:06.000000000 -0400
@@ -0,0 +1,78 @@
+Bug#: 60485
+Product: Mono: Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Blocker
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: martin@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mono_marshal_get_runtime_invoke() cache lookup bug
+
+The following bug is breaking the debugger (which heavily uses runtime invoke):
+
+If you first call mono_runtime_invoke() on a struct method and then call it
+o n another method with the same signature, but in a class,
+mono_marshal_get_runtime_invoke()'s cache lookup mechanism gets confused
+and returns the same wrapper than for the struct method.
+
+If you first invoke the class method and then the struct method, it works fine.
+
+Here's a small test case which shows the problem:
+
+=====
+using System;
+using System.Reflection;
+
+public struct A
+{
+	public override string ToString ()
+	{
+		return "A";
+	}
+}
+
+public class D
+{
+	public string Test ()
+	{
+		return "Test";
+	}
+}
+
+class X
+{
+	static void Main ()
+	{
+		Assembly ass = Assembly.GetCallingAssembly ();
+		Type a_type = ass.GetType ("A");
+		MethodInfo a_method = a_type.GetMethod ("ToString");
+
+		Type d_type = ass.GetType ("D");
+		MethodInfo d_method = d_type.GetMethod ("Test");
+
+		Console.WriteLine ("TEST: {0} {1}", a_method, d_method);
+
+		A a = new A ();
+		D d = new D ();
+
+		object a_ret = a_method.Invoke (a, null);
+		Console.WriteLine (a_ret);
+
+		object d_ret = d_method.Invoke (d, null);
+		Console.WriteLine (d_ret);
+	}
+}
+====
+
+When run, this crashes with an InvalidCastException.
+
+If you swab the two Invoke()s and do the `d_method.Invoke (d, null)' first,
+then it's working fine.