[Mono-bugs] [Bug 59556][Nor] New - Wrong exception when allocating an array of a negative (or unsigned) size

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 3 Jun 2004 10:45:24 -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 sebastien@ximian.com.

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

--- shadow/59556	2004-06-03 10:45:23.000000000 -0400
+++ shadow/59556.tmp.11448	2004-06-03 10:45:23.000000000 -0400
@@ -0,0 +1,70 @@
+Bug#: 59556
+Product: Mono: Runtime
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sebastien@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Wrong exception when allocating an array of a negative (or unsigned) size
+
+Description of Problem:
+Mono throws a OutOfMemoryException where the MS runtime throws a
+OverflowException.
+
+
+Steps to reproduce the problem:
+1. Compile the following source
+
+using System;
+
+class UnsignedSizedArray {
+
+	static void Main () 
+	{
+		try {
+			Console.WriteLine ("new byte [Int32.MaxValue + 1]");
+			byte[] mem = new byte [0x80000000];
+		}
+		catch (OverflowException e) {
+			Console.WriteLine ("Overflow");
+		}
+		catch (OutOfMemoryException) {
+			Console.WriteLine ("OutOfMemory");
+		}
+		catch (Exception e) {
+			Console.WriteLine ("Oops ? {0}", e.ToString ());
+		}
+
+	}
+}
+
+2. Execute it
+
+
+Actual Results (mono runtime):
+new byte [Int32.MaxValue + 1]
+GC Warning: Out of Memory!  Returning NIL!
+OutOfMemory
+
+
+Expected Results (ms runtime):
+new byte [Int32.MaxValue + 1]
+Overflow
+
+
+How often does this happen? 
+Always
+
+
+Additional Information:
+Throwing the OverflowException from the runtime could have the same effect
+as detailled in http://bugzilla.ximian.com/show_bug.cgi?id=59509