Bug 12605 - enum ToString fails on actual device
Summary: enum ToString fails on actual device
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 6.4 (async)
Assignee: Bugzilla
Depends on:
Reported: 2013-06-08 06:59 UTC by tome
Modified: 2013-07-23 05:51 UTC (History)
4 users (show)

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

Enum.ToString test case (1.36 KB, application/octet-stream)
2013-06-08 07:01 UTC, tome

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 Developer Community or GitHub 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:

Description tome 2013-06-08 06:59:11 UTC
ToString of an enum which satisfies below conditions both a) and b), that fails with System.ExecutionEngineException on actual device.
a). enum contains 8 (or more) elements
b). Its underlying type is one of except Int32

For example, that definition is;

public enum MyEnum8ElementsInUInt16 : ushort
	Zero = 0
	, One = 1
	, Two = 2
	, Three = 3
	, Four = 4
	, Five = 5
	, Six = 6
	, Seven = 7

and with such a calling;
Convert.ToString ((MyEnum8ElementsInUInt16)1);

then you will get below messages;

System.ExecutionEngineException : Attempting to JIT compile method 'System.Array:QSortArrange<uint, object> (uint[],object[],int,int)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
at System.Array.qsort[UInt32,Object] (System.UInt32[] keys, System.Object[] items, Int32 low0, Int32 high0) [0x000ee] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Array.cs:2002 
at System.Array.SortImpl (System.Array keys, System.Array items, Int32 index, Int32 length, IComparer comparer) [0x00150] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Array.cs:1451 
at System.Array.Sort (System.Array keys, System.Array items, IComparer comparer) [0x00047] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Array.cs:1344 
at System.MonoEnumInfo.SortEnums (System.Type et, System.Array values, System.Array names) [0x0007d] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Enum.cs:204 
at System.MonoEnumInfo.GetInfo (System.Type enumType, System.MonoEnumInfo& info) [0x00084] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Enum.cs:179 
at System.Enum.GetName (System.Type enumType, System.Object value) [0x0004c] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Enum.cs:399 
at System.Enum.Format (System.Type enumType, System.Object value, System.String format) [0x0013b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Enum.cs:974 
at System.Enum.ToString (System.String format, IFormatProvider provider) [0x0001d] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Enum.cs:691 
at System.Enum.ToString (IFormatProvider provider) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Enum.cs:672 
at System.Convert.ToString (System.Object value, IFormatProvider provider) [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:1691 
 at System.Convert.ToString (System.Object value) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:1685 
 at XamariniOSUnitTest.EnumTest.EnumToStringTest () [0x00016] in /Users/tome/devel/Projects/TestLib/XamariniOSUnitTest/EnumTest.cs:68 

Please check the attached test case.
FYI On 6.2.x is OK indeed.

I actually understand that this is just an alpha version yet but the porting is not so easy for client side also.
I only want the PIE (Position Independent Executable) feature of 6.3.6 to release apps to the Apple iTunes Store.
Don't you have a plan to backport that into 6.2.x ?

Comment 1 tome 2013-06-08 07:01:02 UTC
Created attachment 4085 [details]
Enum.ToString test case
Comment 2 Rolf Bjarne Kvinge [MSFT] 2013-06-10 16:29:06 UTC
Note that Apple only warns about your executable not being PIE - they don't prevent you from publishing it. In any case we are planning to backport that fix to 6.2.*, but we don't have a firm date yet.
Comment 4 Sebastien Pouliot 2013-07-04 17:18:42 UTC
I added your test case to our unit tests and it works fine with the latest 6.3.7, IOW it's already fixed. Please update (there's a lot of similar fixes) and let us know if you encounter similar issues.
Comment 5 Sebastien Pouliot 2013-07-04 17:27:39 UTC
QA: unit tests added in master-3.0 34051799b26697df30e480ac9411351d5cfc187b
Comment 6 narayanp 2013-07-23 05:51:03 UTC
Today we have checked this issue with following builds:

Mac Lion 10.7.4
X.S 4.0.10(build 7)
Mono 3.1.2
Xamarin.iOS 6.4.0-2

We have created a iOS Unit Test project and added attached file in this project and run the application on iOS device. This is working fine and we are able to navigate to EnumTest. This is the gist of output: https://gist.github.com/saurabh360/60c90f52133baed80949

Changing the status to Verified.