[Mono-bugs] [Bug 81102][Wis] New - Mono incorrectly labels certain IL sequences as invalid

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Mar 10 02:08:27 EST 2007


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 dmitchell at logos.com.

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

--- shadow/81102	2007-03-10 02:08:27.000000000 -0500
+++ shadow/81102.tmp.7983	2007-03-10 02:08:27.000000000 -0500
@@ -0,0 +1,104 @@
+Bug#: 81102
+Product: Mono: Runtime
+Version: 1.0
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: JIT
+AssignedTo: lupus at ximian.com                            
+ReportedBy: dmitchell at logos.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mono incorrectly labels certain IL sequences as invalid
+
+Please fill in this template when reporting a bug, unless you know what you are doing.
+Description of Problem:
+
+Here's some code:
+using System;
+
+namespace MonoBug
+{
+	public class Foo<T1>
+	{
+		public Foo(T1 t1)
+		{
+			m_t1 = t1;
+		}
+		
+		public override string ToString()
+		{
+			return Bar(m_t1 == null ? "null" : m_t1.ToString());
+		}
+		
+		public string Bar(string argument) { return argument; }
+		
+		readonly T1 m_t1;
+	}
+	
+	public class Bar
+	{
+		public Bar(int a)
+		{
+			m_str = a;
+		}
+
+		public override string ToString()
+		{
+			return Foo(m_str == null ? "null" : m_str.ToString());
+		}
+
+		public string Foo(string argument)
+		{
+			return argument;
+		}
+
+		readonly int? m_str;
+	}
+	
+	public class InvalidILTest
+	{
+		public static void Main()
+		{
+			Console.WriteLine(new Bar(5));
+			Console.WriteLine(new Foo<string>("hello"));
+			Console.WriteLine(new Foo<int?>(5));
+			Console.WriteLine(new Foo<int>(5));
+		}
+	}
+}
+
+The first three calls to Console.WriteLine succeed. However, the last one fails because of a 
+System.InvalidProgramException: Invalid IL code in MonoBug.Foo`1:ToString (): IL_002f: call      
+0x0a000004.
+
+The reason that this exception is thrown seems to be that a call to handle_stack_args (in mini.c) 
+discovers that the actual count of items on the stack is greater than expected.
+
+I suspect this has something to do with the fact that we are comparing a value type to null; 
+perhaps the JITter ignores this check and puts both values on the stack? I'm not sure...
+
+I can verify that this is a bug with the runtime in parsing the IL code. After compiling this code 
+under Mono, I ran it in Microsoft's .NET without any problems.
+
+
+Steps to reproduce the problem:
+1. Compile the code above
+2. Run it
+3. boom.
+
+Actual Results:
+InvalidProgramException is thrown
+
+Expected Results:
+Program should complete normally
+
+How often does this happen? 
+Always
+
+Additional Information:


More information about the mono-bugs mailing list