Bug 12895 - AOT compilation of Regex
Summary: AOT compilation of Regex
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Pre-release ()
Version: 6.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 6.4 (async)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-06-26 08:49 UTC by Iain
Modified: 2013-07-08 07:57 UTC (History)
3 users (show)

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


Attachments
demo project (3.84 MB, application/zip)
2013-06-26 08:49 UTC, Iain
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 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:
Status:
VERIFIED FIXED

Description Iain 2013-06-26 08:49:57 UTC
Created attachment 4204 [details]
demo project

Using mtouch alpha: 6.3.6.77 (fa63be7)

Getting an AOT related exception at runtime constructing a regex (it's failing to JIT QSortArrange in Enum.Parse).

**May be a duplicate of bug #12605.**  Looks pretty similar...


Instructions: debug the attached project or create a new monotouch project and add the following lines somewhere within the AppDelegate FinishedLaunching:



try{
			Regex r = new Regex (@"(?<whitespace>\G[	 ]+)|(?<newline>\G?
)|(?<symbol>\G[][{}:,])|(?<identifier>\G[A-Za-z]+)|(?<string>\G
	            \""                              # Opening quote
	            (?:
	              \\u[0-9a-fA-F]{4}           |  # Unicode escape
	              \\b | \\f | \
 | \ | \	 |  # Backspace, form-feed, newline, carriage-return, tab
	              \\\\ | \\/ |                   # Escaped backslash, slash
	              \\"" |                         # Escaped quotes
	              [^\p{Cc}\\""]                  # Any unicode character except a control code, a backslash or a double quote
	            )*                               # Zero of more of any of the previous classes
	            \""                              # Closing quote
	            )|(?<number>\G
	            -?                             # Optional minus
	            (?:
	              0 |                          # Leading zero only allowed on its own (e.g. 0, 0.1, 0e1)
	              [1-9][0-9]*                   # Otherwise leading digit must be non-zero (so no 0123, 0001)
	            )
	            (?:[.][0-9]*)?                 # Optional fraction
	            (?:[Ee][+-]?[0-9]+)?           # Optional exponent
	            (?![A-Za-z0-9_])               # Must not be followed by an alphanumeric character
	            )", RegexOptions.IgnorePatternWhitespace);
			}catch(Exception ex) {
				Console.WriteLine ("Exception: " + ex);
				throw;
			} 


Stacktrace as follows:


Exception: System.ExecutionEngineException: Attempting to JIT compile method 'System.Array:QSortArrange<uint16, object> (uint16[],object[],int,int)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
	
	  at System.Array.qsort[UInt16,Object] (System.UInt16[] 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) [0x0013c] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Array.cs:1448 
	  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.Parse[Object] (System.Type enumType, System.String value, Boolean ignoreCase, System.Object& result) [0x00000] in <filename unknown>:0 
	  at System.Enum.Parse (System.Type enumType, System.String value, Boolean ignoreCase) [0x00061] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Enum.cs:520 
	  at System.Text.RegularExpressions.CategoryUtils.CategoryFromName (System.String name) [0x00019] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/category.cs:209 
	  at System.Text.RegularExpressions.Syntax.Parser.ParseUnicodeCategory () [0x00053] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/parser.cs:793 
	  at System.Text.RegularExpressions.Syntax.Parser.ParseCharacterClass (RegexOptions options) [0x001c9] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/parser.cs:698 
	  at System.Text.RegularExpressions.Syntax.Parser.ParseGroup (System.Text.RegularExpressions.Syntax.Group group, RegexOptions options, System.Text.RegularExpressions.Syntax.Assertion assertion) [0x00178] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/parser.cs:227 
	  at System.Text.RegularExpressions.Syntax.Parser.ParseGroupingConstruct (System.Text.RegularExpressions.RegexOptions& options) [0x000f9] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/parser.cs:408 
	  at System.Text.RegularExpressions.Syntax.Parser.ParseGroup (System.Text.RegularExpressions.Syntax.Group group, RegexOptions options, System.Text.RegularExpressions.Syntax.Assertion assertion) [0x0018e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/parser.cs:233 
	  at System.Text.RegularExpressions.Syntax.Parser.ParseGroupingConstruct (System.Text.RegularExpressions.RegexOptions& options) [0x0029d] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/parser.cs:477 
	  at System.Text.RegularExpressions.Syntax.Parser.ParseGroup (System.Text.RegularExpressions.Syntax.Group group, RegexOptions options, System.Text.RegularExpressions.Syntax.Assertion assertion) [0x0018e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/parser.cs:233 
	  at System.Text.RegularExpressions.Syntax.Parser.ParseRegularExpression (System.String pattern, RegexOptions options) [0x00031] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/parser.cs:140 
	  at System.Text.RegularExpressions.Regex.CreateMachineFactory (System.String pattern, RegexOptions options) [0x00006] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/Regex.cs:344 
	  at System.Text.RegularExpressions.Regex.InitNewRegex () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/Regex.cs:325 
	  at System.Text.RegularExpressions.Regex.Init () [0x00027] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/Regex.cs:313 
	  at System.Text.RegularExpressions.Regex..ctor (System.String pattern, RegexOptions options) [0x0002b] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Text.RegularExpressions/Regex.cs:215 
	  at TestRegexAOTBug.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x000b6] in /Users/iainm/Projects/TestRegexAOTBug/TestRegexAOTBug/AppDelegate.cs:57
Comment 1 Sebastien Pouliot 2013-07-04 14:50:54 UTC
The attached project works fine in 6.9.3 (alpha) which has an identical runtime to 6.3.7 (beta). I'll re-test it once I go back to beta but I encourage you to try the latest version (since several fixes were made regarding similar issues).
Comment 2 Sebastien Pouliot 2013-07-05 09:12:45 UTC
QA: unit test added in master-3.0 6b198c3b2eb476358f3edda0a367f092145e7754
Comment 3 Atin 2013-07-08 07:57:59 UTC
Today, We have checked this issue with following builds:

All mac
XS 4.0.9(build 15)
MT 6.3.7.177
Mono 3.1.0 ((no/1c4db5e)

We have debug the attached project and also created a new ios template and add the code mentioned above in the bug and run that project.

Now its compiling successfully without any error. Hence marking this as verified fixed.