[Mono-bugs] [Bug 40646][Maj] New - mcs doesn't parse correctly array initializers

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Tue, 1 Apr 2003 19:18:59 -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 eureko@grmexico.com.mx.

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

--- shadow/40646	Tue Apr  1 19:18:59 2003
+++ shadow/40646.tmp.32754	Tue Apr  1 19:18:59 2003
@@ -0,0 +1,142 @@
+Bug#: 40646
+Product: Mono/MCS
+Version: unspecified
+OS: Mandrake 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: eureko@grmexico.com.mx               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs doesn't parse correctly array initializers
+
+/*
+BUG REPORT
+
+Summary:
+--------
+mcs doesn't parse correctly array initializers
+
+Bug description:
+----------------
+mono drops at runtime: CRITICAL **: file metadata.c: line 785
+(mono_metadata_blob_heap): assertion index < meta->heap_blob.size' failed
+The same program compiled with csc runs ok (linux and windows), but
+compiled with mcs it breaks with this error.
+
+The bug can be reproduced with the source code provided.
+
+Actual Results:
+-----------------------------
+Bidimensional array of Friend
+
+
+** (bugfound-mcs-linux.exe:1680): CRITICAL **: file metadata.c: line 785
+(mono_metadata_blob_heap): assertion index < meta->heap_blob.size' failed
+
+** ERROR **: type 0x3d not handled in mono_metadata_parse_type
+aborting...
+Aborted
+
+
+Expected Results:
+-----------------------------
+Bidimensional array of Friend
+
+i = 0; j = 0; Pa (66 years old)
+i = 0; j = 1; Miguel (26 years old)
+i = 1; j = 0; Pepe (28 years old)
+i = 1; j = 1; unknown (-1 years old)
+i = 2; j = 0; Oscar (27 years old)
+i = 2; j = 1; unknown (-1 years old)
+i = 3; j = 0; unknown (-1 years old)
+i = 3; j = 1; unknown (-1 years old)
+
+
+How often does this happen? 
+---------------------------
+Always running this program
+
+
+Additional Information:
+-----------------------
+I think mcs doesn't parse ok the array initializers like this one:
+	friends = new Friend[4, 2] {
+		{ new Friend("Pa", 66), new Friend("Miguel", 26) },
+		{ new Friend("Pepe", 28), new Friend() },
+		{ new Friend("Oscar", 27), new Friend() },
+		{ new Friend(), new Friend() }
+	};
+Running the mcs generated image with the .net runtime,
+it says that the index is out of bounds, but the same code runs ok
+if it is compiled with csc.
+Unfortunately, I can only use mcs on linux, since my win is 98, and
+no updated version of mono runs over that.
+
+*/
+
+using System;
+
+namespace Eureko.Samples {
+	class ArraysApp {
+		public static void Main() {
+			Bidimensional bidimArray = new Bidimensional();
+			
+			Console.WriteLine("\n-----------------------------");
+			Console.WriteLine("Bidimensional array of Friend\n");
+			bidimArray.DisplayResults();
+		}
+	}
+	
+	class Friend {
+		public Friend(string friendname, int friendage) {
+			name = friendname;
+			age = friendage;
+		}
+		
+		public Friend() {
+			name = "unknown";
+			age = -1;
+		}
+		
+		protected string name;
+		public string Name {
+			get { return name; }
+			set { name = value; }
+		}
+		
+		protected int age;
+		public int Age {
+			get { return age; }
+			set { age = value; }
+		}
+	}
+	
+	class Bidimensional {
+		protected Friend[,] friends;
+		
+		public void DisplayResults() {
+			for(int i = 0; i<friends.GetLength(0); i++)
+				for(int j = 0; j<friends.GetLength(1); j++) {
+					Console.Write("i = {0}; j = {1}; ", i, j);
+					Console.WriteLine(((Friend) friends[i, j]).Name + " ({0} years old)",
+((Friend) friends[i, j]).Age);
+				}
+		}
+		
+		public Bidimensional() {
+			friends = new Friend[4, 2] {
+				{ new Friend("Pa", 66), new Friend("Miguel", 26) },
+				{ new Friend("Pepe", 28), new Friend() },
+				{ new Friend("Oscar", 27), new Friend() },
+				{ new Friend(), new Friend() }
+			};
+		}
+	}
+}