Bug 29183 - Array constructor fails to construct multi bound array
Summary: Array constructor fails to construct multi bound array
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-04-17 06:17 UTC by Marek Safar
Modified: 2015-04-17 15:06 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Marek Safar 2015-04-17 06:17:25 UTC
using System.Reflection;
using System;
using System.Linq;

class X
{
	public static void Main ()
	{
		var type1 = Type.GetType ("System.Char[,]").GetTypeInfo ();
		var ci = type1.DeclaredConstructors.First (l => l.GetParameters ().Length == 4);
		var res = ci.Invoke (new object[] { 1, 5, -10, 7 });
	}
}

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.OverflowException: Arithmetic operation resulted in an overflow.
  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00009] in /Users/marek/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:651 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00018] in /Users/marek/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:657 
  at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000a1] in /Users/marek/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:642 
  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00008] in /Users/marek/git/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:670 
  at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00016] in
Comment 1 Zoltan Varga 2015-04-17 13:19:40 UTC
Shouldn't the lower bounds come first, and the lengths after them ?
Comment 2 Marek Safar 2015-04-17 14:04:21 UTC
Yes, so it should create an array of char[1..5, -10..-4]
Comment 3 Zoltan Varga 2015-04-17 15:06:14 UTC
Fixed in mono master 8de00a141d127352e2af3dba91dd1860791e05ba.