[Mono-bugs] [Bug 43783][Min] New - Array.Sort (Array, int, int) does not check for invalid arguments

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Tue, 27 May 2003 23:23:21 -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 bmaurer@users.sf.net.

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

--- shadow/43783	Tue May 27 23:23:21 2003
+++ shadow/43783.tmp.4715	Tue May 27 23:23:21 2003
@@ -0,0 +1,92 @@
+Bug#: 43783
+Product: Mono/Class Libraries
+Version: unspecified
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Array.Sort (Array, int, int) does not check for invalid arguments
+
+Description of Problem:
+Array.Sort (Array, int, int) does not check for values outside the bounds
+of the array. Thus, when given such arguments an IndexOutOfRange exception
+is thrown. It should throw an ArgumentOutOfRange exception.
+
+Steps to reproduce the problem:
+using System;
+
+public class Bug {
+	public static int Main () {
+		int [] oArrValues = new int [] { 1, 2, 4, 3, 5 };
+		int ret = 3;
+		try {
+			Array.Sort(oArrValues, -1, 3);
+			ret = 2;
+		} catch (ArgumentException ex) {
+			ret = 0;
+		} catch (Exception ex) {
+			ret = 1;
+			Console.WriteLine("Wrong Exception thrown:" + ex.ToString());
+			Console.WriteLine(ex.StackTrace);
+		}
+		return ret;
+	}
+}
+
+Actual Results:
+Wrong Exception thrown:System.IndexOutOfRangeException: Array index is out of r
+ange
+in (unmanaged) /devel/install//lib/libmono.so.0(mono_raise_exception+0x20)
+[0x40
+08d161]
+in (unmanaged) /devel/install//lib/libmono.so.0 [0x4008e918]
+in <0x00046> 00 System.Array:GetValue (int)
+in <0x00037> 00 System.Array:swap (System.Array,System.Array,int,int)
+in <0x00160> 00 System.Array:qsort
+(System.Array,System.Array,int,int,System.Col
+lections.IComparer)
+in <0x001b0> 00 System.Array:qsort
+(System.Array,System.Array,int,int,System.Col
+lections.IComparer)
+in <0x00048> 00 System.Array:Sort
+(System.Array,System.Array,int,int,System.Coll
+ections.IComparer)
+in <0x0001a> 00 System.Array:Sort (System.Array,int,int)
+in <0x000de> 00 .Bug:Main ()
+ 
+in (unmanaged) /devel/install//lib/libmono.so.0(mono_raise_exception+0x20) [0x4
+008d161]
+in (unmanaged) /devel/install//lib/libmono.so.0 [0x4008e918]
+in <0x00046> 00 System.Array:GetValue (int)
+in <0x00037> 00 System.Array:swap (System.Array,System.Array,int,int)
+in <0x00160> 00 System.Array:qsort
+(System.Array,System.Array,int,int,System.Col
+lections.IComparer)
+in <0x001b0> 00 System.Array:qsort
+(System.Array,System.Array,int,int,System.Col
+lections.IComparer)
+in <0x00048> 00 System.Array:Sort
+(System.Array,System.Array,int,int,System.Coll
+ections.IComparer)
+in <0x0001a> 00 System.Array:Sort (System.Array,int,int)
+in <0x000de> 00 .Bug:Main ()
+
+
+Expected Results:
+Program should run with no output and should return an exit code of 0.
+
+How often does this happen? 
+Always.
+
+Additional Information:
+ROTORFAILURE: array/co3770sort_oii.cs
+Error E_856df