Bug 7712 - error MT0000: Unexpected error : System.ArgumentOutOfRangeException
Summary: error MT0000: Unexpected error : System.ArgumentOutOfRangeException
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
: 7717 ()
Depends on:
Blocks:
 
Reported: 2012-10-07 13:55 UTC by Jochen Hansmeyer
Modified: 2014-10-12 06:05 UTC (History)
5 users (show)

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


Attachments
Testcase (1.49 MB, application/x-tar)
2012-10-08 10:04 UTC, Jochen Hansmeyer
Details
FluentValidation Testcase (172.82 KB, application/octet-stream)
2012-10-08 20:14 UTC, sean.blakemore
Details
Other Testcase (6.33 MB, application/x-tar)
2012-10-09 06:02 UTC, Jochen Hansmeyer
Details


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 Jochen Hansmeyer 2012-10-07 13:55:54 UTC
Compiling to native code
/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" -v --cache "/Users/cjh/Projects/MonoTouch/Navigator/obj/Debug/mtouch-cache" --nomanifest --nosign -sim "/Users/cjh/Projects/MonoTouch/Navigator/bin/iPhoneSimulator/Debug/Navigator.app" -r "/Users/cjh/Projects/MonoTouch/AForge.NET/Math/bin/Debug/Math.dll" -r "/Users/cjh/Projects/MonoTouch/AForge.NET/Core/bin/Debug/Core.dll" -r "/Users/cjh/Projects/MonoTouch/NTS/bin/Debug/NTS.dll" -r "/Users/cjh/Projects/MonoTouch/SharpZipLib/bin/Debug/SharpZipLib.dll" -r "/Users/cjh/Projects/MonoTouch/MonoTouch.Dialog/MonoTouch.Dialog/bin/iPhoneSimulator/Debug/MonoTouch.Dialog.dll" -r "/Users/cjh/Projects/MonoTouch/Accord.NET/Sources/Accord.Core/bin/Debug/Accord.Core.dll" -r "/Users/cjh/Projects/MonoTouch/Accord.NET/Sources/Accord.Math/bin/Debug/Accord.Math.dll" -r "/Users/cjh/Projects/MonoTouch/Accord.NET/Sources/Accord.Statistics/bin/Debug/Accord.Statistics.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -r "/Users/cjh/Projects/MonoTouch/Navigator/Library/log4net.dll" -r "/Users/cjh/Projects/MonoTouch/Navigator/Library/Mapview.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Runtime.Serialization.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.Linq.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Data.dll" -r "/Users/cjh/Projects/MonoTouch/Navigator/Library/CorePlotiOS.dll" -r "/Users/cjh/Projects/MonoTouch/Navigator/Library/WFConnector.dll" -debug -profiling -linksdkonly "-i18n=west" -sdk "6.0" -targetver "5.0" --sgen --armv7 --gcc_flags "\"-cclib\" \"-L/Users/cjh/Projects/MonoTouch/Navigator/Library\" \"-lSpatialite\" \"-force_load\" \"/Users/cjh/Projects/MonoTouch/Navigator/Library/libSpatialite.a\" \"-lSqlite\" \"-force_load\" \"/Users/cjh/Projects/MonoTouch/Navigator/Library/libSqlite.a\"" "/Users/cjh/Projects/MonoTouch/Navigator/bin/iPhoneSimulator/Debug/Rowing.exe"
MonoTouch version 6.0.2 using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk
error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
System.ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count.
Parameter name: index
0
  at System.Collections.ArrayList.ThrowNewArgumentOutOfRangeException (System.String name, System.Object actual, System.String message) [0x00000] in <filename unknown>:0 
  at System.Collections.ArrayList.get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at System.Collections.CollectionBase.System.Collections.IList.get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.GenericParameterCollection.get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ReflectionReader.GetTypeRefFromSig (Mono.Cecil.Signatures.SigType t, Mono.Cecil.GenericContext context) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ReflectionReader.GetGenericArg (Mono.Cecil.Signatures.GenericArg arg, Mono.Cecil.GenericContext context) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ReflectionReader.GetTypeRefFromSig (Mono.Cecil.Signatures.SigType t, Mono.Cecil.GenericContext context) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ReflectionReader.CompleteParameter (Mono.Cecil.ParameterDefinition parameter, Mono.Cecil.Signatures.Param signature, Mono.Cecil.GenericContext context) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ReflectionReader.BuildParameterDefinition (System.String name, Int32 sequence, ParameterAttributes attrs, Mono.Cecil.Signatures.Param psig, Mono.Cecil.GenericContext context) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ReflectionReader.CompleteMethods () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ReflectionReader.VisitTypeDefinitionCollection (Mono.Cecil.TypeDefinitionCollection types) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AggressiveReflectionReader.VisitTypeDefinitionCollection (Mono.Cecil.TypeDefinitionCollection types) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ReflectionReader.VisitModuleDefinition (Mono.Cecil.ModuleDefinition mod) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.StructureReader.TerminateAssemblyDefinition (Mono.Cecil.AssemblyDefinition asm) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyDefinition.Accept (IReflectionStructureVisitor visitor) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyFactory.GetAssembly (Mono.Cecil.Binary.ImageReader irv, Boolean manifestOnly) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyFactory.GetAssembly (Mono.Cecil.Binary.ImageReader reader) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyFactory.GetAssembly (System.String file) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.MonoTouchResolver.ReadAssembly (System.String file) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.MonoTouchResolver.AddAssembly (System.String fileName) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.MonoTouchResolver.SearchDirectory (System.String name, System.String directory) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.MonoTouchResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.MonoTouchResolver.Resolve (System.String fullName) [0x00000] in <filename unknown>:0 
  at MonoTouch.Tuner.MonoTouchResolver.GetAssembly (System.String fileName) [0x00000] in <filename unknown>:0 
  at MTouch.ExtractNativeLinkInfo (System.String project_root, System.Collections.Generic.List`1 references) [0x00000] in <filename unknown>:0 
  at MTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0 
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-10-08 06:33:44 UTC
My first guess is that one of your assemblies references an assembly you're not referencing.

But do you have a test project we can try this out with? That way we could easily confirm my theory (or deny it and find the real issue).
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-10-08 06:36:00 UTC
*** Bug 7717 has been marked as a duplicate of this bug. ***
Comment 3 Jochen Hansmeyer 2012-10-08 06:54:24 UTC
I try to use mathematics/statistics libraries Accord.NET which depends on AForge.NET. I have all projects in my solution and double checked all references. 

These are large libraries with a few thousand classes. Maybe it is simpler to look at the duplicate of this bug first.

Please let me know, if you prefer to look into this first instead. Then i will try to prepare a test project.
Comment 4 Jochen Hansmeyer 2012-10-08 10:04:58 UTC
Created attachment 2706 [details]
Testcase

Please expand, open solution Accord.NET and try to build all
Comment 5 Rolf Bjarne Kvinge [MSFT] 2012-10-08 17:27:57 UTC
I tried the solution, and it seems to be missing the Accord.Tests project.

In the Any CPU configuration everything builds fine, if I switch to iPhoneSimulator there is nothing to build (all the projects are greyed out, except Accord.Tests which is red because it's missing).
Comment 6 sean.blakemore 2012-10-08 20:14:00 UTC
Created attachment 2714 [details]
FluentValidation Testcase

Attached is a testcase for what looks to be the exact same bug. Solution contains three projects, a .Net 4 library, a MT library with the files from the .Net 4 library added as links and finally an MT iPad app.

The .Net 4 and MT libraries build with no problem. Referencing the MT library from the MT iPad app it will still build but with warning:
Warning: The referenced library 'FluentValidation.MonoTouch.dll' is not used from any code, skipping extraction of content resources.

As soon as any code from the referenced library is used in the iPad app it will fail to build.
Comment 7 Rolf Bjarne Kvinge [MSFT] 2012-10-08 20:55:40 UTC
I can reproduce this with the project from comment 6. I'll have a look at it tomorrow.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2012-10-09 05:40:24 UTC
This seems to be a compiler bug.

Paste this into any MonoTouch project (you'll need to reference System.Core and add 'using System.Linq;' too):

static object Method <T>(object[] objects)
{
    return objects.Select(obj => new Func<T, object>(x => obj));
}

and you'll get this error.

peverify complains about the assembly too:

> MONO_PATH=/Developer/MonoTouch/usr/lib/mono/2.1/ peverify MonoTouchTest.exe
Could not load signature of MonoTouchTest.Application+<Method>c__AnonStorey0`1[T]:<>m__1 due to: 
Missing method MonoTouchTest.Application.<Method>c__AnonStorey0<T>::<>m__1(!!0) in assembly /Users/rolf/Library/Caches/Opera/temporary_downloads/fluentvalidation/src/MonoTouchTest/bin/iPhoneSimulator/Debug/MonoTouchTest.exe, referenced in assembly /Users/rolf/Library/Caches/Opera/temporary_downloads/fluentvalidation/src/MonoTouchTest/bin/iPhoneSimulator/Debug/MonoTouchTest.exe
In method: MonoTouchTest.Application::<Method`1>m__0(object)
Error: Cannot load method from token 0x0a000008 for ldftn at 0x000e
Could not load signature of MonoTouchTest.Application+<Method>c__AnonStorey0`1[T]:<>m__1 due to: 
Could not load signature of MonoTouchTest.Application+<Method>c__AnonStorey0`1[T]:<>m__1 due to: 
In method: MonoTouchTest.Application/<Method>c__AnonStorey0`1::<>m__1(ERROR)
Error: Could not decode method signature
Error count: 2
Comment 9 Jochen Hansmeyer 2012-10-09 06:02:30 UTC
Created attachment 2716 [details]
Other Testcase

Here again my test case, now complete. I send it again, because it does not use System.Linq.
Comment 10 sean.blakemore 2012-10-10 01:36:46 UTC
Ahh great, thanks Rolf, that at least gives me a workaround...

var list = new List<Func<T, object>>();
Array.ForEach (objects, obj => list.Add(new Func<T, object>(x => obj)));
return list.ToArray();
Comment 11 Marek Safar 2012-10-10 10:02:17 UTC
Already fixed in Mono 2.11