[Mono-bugs] [Bug 71454][Wis] New - indexing into multidimensional arrays generates NullReferenceException
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 19 Jan 2005 07:29:19 -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 jonpryor@vt.edu.
http://bugzilla.ximian.com/show_bug.cgi?id=71454
--- shadow/71454 2005-01-19 07:29:19.000000000 -0500
+++ shadow/71454.tmp.30062 2005-01-19 07:29:19.000000000 -0500
@@ -0,0 +1,97 @@
+Bug#: 71454
+Product: Mono: Runtime
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: JIT
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: jonpryor@vt.edu
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: indexing into multidimensional arrays generates NullReferenceException
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+From Mike Welham:
+
+I've been working with multidimensional arrays and have run into some
+code that compiles fine with both mcs and Microsoft's C# compiler, runs
+fine in Microsoft's runtime and with mint, but throws a
+NullReferenceException with mono.
+
+(I'm not sure the problem is tied to multidimensional arrays - it's just
+that it is the only place that I've managed to replicate it.)
+
+The code below demonstrates the problem. The commented-out (functionally
+equivalent) version in the sample runs fine.
+
+More info that I hope will help: Mono 1.0.5 on WinXP SP2 x86. The
+assembly verifies fine with Microsoft's PEVerify.
+
+Steps to reproduce the problem:
+1. Compile the following code: mcs jitbug.cs
+
+ // Possible JIT bug...
+ using System;
+
+ class Host
+ {
+ public static void Main()
+ {
+ int[,] a = new int[4,4];
+ for(int i = 0; i < 4; ++i)
+ {
+ for(int j = 0; j < 4; ++j)
+ {
+ a[i, j] = i + j;
+ }
+ }
+
+ int[,] b = new int[4,4];
+ for(int i = 0; i < 4; ++i)
+ {
+ for(int j = 0; j < 4; ++j)
+ {
+ // NullReferenceException thrown here:
+ b[i,j] = a[0,(i + j) % 4];
+
+ // This (equivalent) code works fine:
+ // int c = (i + j) % 4;
+ // b[i,j] = a[0,c];
+ }
+ }
+ }
+ }
+
+
+2. Execute it with mono: mono jitbug.exe
+
+
+Actual Results:
+
+ Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+ in <0x00162> Host:Main ()
+
+Expected Results:
+
+No exception.
+
+How often does this happen?
+
+All the time.
+
+Additional Information:
+
+This also generates a NullReferenceException on svn-HEAD.
+
+See also:
+http://lists.ximian.com/archives/public/mono-list/2005-January/025349.html