Bug 14696 - Xamarin.iOS 6.4.4.12 Bug with Async Service Calls
Summary: Xamarin.iOS 6.4.4.12 Bug with Async Service Calls
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.4.4
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
: 14656 ()
Depends on:
Blocks:
 
Reported: 2013-09-12 15:25 UTC by Jon Goldberger [MSFT]
Modified: 2013-09-17 08:11 UTC (History)
3 users (show)

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


Attachments
Build Log (144.88 KB, text/plain)
2013-09-12 17:41 UTC, Jon Goldberger [MSFT]
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:
RESOLVED FIXED

Description Jon Goldberger [MSFT] 2013-09-12 15:25:49 UTC
We recently noticed an issue when we deployed our app to an iOS device where our service calls started to fail. After some extended debugging and troubleshooting we've determined that something that changed between Xamarin.iOS 6.4.3 and 6.4.4 introduced a bug. Our service calls now return the following exception:

[0:] Error getting response stream (ReadDone1): ReceiveFailure
System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-begin-invoke) System.Func`4<byte[], int, int, int>:begin_invoke_IAsyncResult__this___T1_T2_T3_AsyncCallback_object (byte[],int,int,System.AsyncCallback,object)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.

at System.IO.Stream.BeginRead (System.Byte[] buffer, Int32 offset, Int32 count, System.AsyncCallback callback, System.Object state) [0x00072] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/Stream.cs:191
at Mono.Security.Protocol.Tls.RecordProtocol.BeginReceiveRecord (System.IO.Stream record, System.AsyncCallback callback, System.Object state) [0x00039] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:326
at Mono.Security.Protocol.Tls.RecordProtocol.ReceiveRecord (System.IO.Stream record) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:441
at Mono.Security.Protocol.Tls.SslStreamBase.InternalReadCallback (IAsyncResult result) [0x00091] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs:682
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:951
at System.ServiceModel.Channels.HttpRequestChannel.GotResponse (IAsyncResult result) [0x0001f] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:210
2013-09-12 13:19:43.531 DirectEnergyMobileOAMClientiOS[7092:7607] Error getting response stream (ReadDone1): ReceiveFailure
System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-begin-invoke) System.Func`4<byte[], int, int, int>:begin_invoke_IAsyncResult__this___T1_T2_T3_AsyncCallback_object (byte[],int,int,System.AsyncCallback,object)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.

at System.IO.Stream.BeginRead (System.Byte[] buffer, Int32 offset, Int32 count, System.AsyncCallback callback, System.Object state) [0x00072] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/Stream.cs:191
at Mono.Security.Protocol.Tls.RecordProtocol.BeginReceiveRecord (System.IO.Stream record, System.AsyncCallback callback, System.Object state) [0x00039] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:326
at Mono.Security.Protocol.Tls.RecordProtocol.ReceiveRecord (Sy
stem.IO.Stream record) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:441
at Mono.Security.Protocol.Tls.SslStreamBase.InternalReadCallback (IAsyncResult result) [0x00091] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs:682
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:951
at System.ServiceModel.Channels.HttpRequestChannel.GotResponse (IAsyncResult result) [0x0001f] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:210


Here is the code (debug logging added temporarily to assist with trouble shooting):

public void GetNotifications(CancelableAction<OAMNotification[]> resultingAction)
{
HandleUtility<OAMNotification[]>(resultingAction.RunResultingAction,
(c) =>
{
c.BeginGetNotifications(UtilityServiceReference.OAMBrand.DER,
(r) =>
{
try { resultingAction.RunResultingAction(TranslationHelper.FromService(c.EndGetNotifications(r))); }
catch (Exception e) {
System.Diagnostics.Debug.WriteLine(string.Format(@"{1}{0}{2}{0}{3}",
Environment.NewLine,
e.Message,
e.InnerException,
e.StackTrace));
resultingAction.RunResultingAction(null);
}
},
null);
},
null);
}

private void HandleUtility<T>(Action<T> resultingAction, Action<IUtilityService> action, T errorValue)
{
try { action(_serviceFactory.GetUtilityServiceClient()); }
catch { resultingAction(errorValue); }
}

To be sure it wasn't an issue with the generics in HandleUtility we refactored the code to not use the generics and still received the same error. Downgrading to 6.4.3 resolved the issue. I've updated to the latest Xamarin.iOS (6.4.5) and the exception is still thrown. Since this is a JIT vs AOT compilation issue the issue does not occur on the simulator.
Comment 2 Sebastien Pouliot 2013-09-12 15:41:05 UTC
awaiting full build log
Comment 3 Jon Goldberger [MSFT] 2013-09-12 17:22:32 UTC
Version info (Build logs coming)


Here is the VS2012 info:
Microsoft Visual Studio Premium 2012
Version 11.0.60610.01 Update 3
Microsoft .NET Framework
Version 4.5.50709

Installed Version: Premium

LightSwitch for Visual Studio 2012 04941-004-0043007-02977
Microsoft LightSwitch for Visual Studio 2012

Office Developer Tools 04941-004-0043007-02977
Microsoft Office Developer Tools

Team Explorer for Visual Studio 2012 04941-004-0043007-02977
Microsoft Team Explorer for Visual Studio 2012

Visual Basic 2012 04941-004-0043007-02977
Microsoft Visual Basic 2012

Visual C# 2012 04941-004-0043007-02977
Microsoft Visual C# 2012

Visual C++ 2012 04941-004-0043007-02977
Microsoft Visual C++ 2012

Visual F# 2012 04941-004-0043007-02977
Microsoft Visual F# 2012

Visual Studio 2012 Code Analysis Spell Checker 04941-004-0043007-02977
Microsoft® Visual Studio® 2012 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Visual Studio 2012 SharePoint Developer Tools 04941-004-0043007-02977
Microsoft Visual Studio 2012 SharePoint Developer Tools

NuGet Package Manager 2.7.40808.167
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer 1.0
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools 11.1.20905.0
Microsoft SQL Server Data Tools

Web Developer Tools 1.2.40308.0
Microsoft Web Developer Tools contains the following components:
Page Inspector: Tool that offers an efficient way to decompose Web Applications and diagnose front-end issues.
Web Publishing: Extensions required for Web Publishing for both hosted servers as well as on premises.
Web Form Templates: Includes the default templates for Web Form Applications.
Editor Extensions: Includes HTML, CSS, and JS editor extensions that greatly enhance the development experience.

Windows Azure Tools October 2012
Windows Azure Tools for Microsoft Visual Studio 2012 - October 2012 v1.8.51019.1603

Xamarin.Android 4.8.01013 (b76e8ec4)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 1.3.250 (49348a51)
Visual Studio extension to enable development for Xamarin.iOS

I’ll update to the latest Xamarin.iOS version in order to generate the verbose build output. Creating a small project to replicate the issue might be possible but I probably won’t be able to send that over until early next week as we are wrapping up an iteration tomorrow.
Comment 4 Jon Goldberger [MSFT] 2013-09-12 17:41:06 UTC
Created attachment 4863 [details]
Build Log
Comment 5 Sebastien Pouliot 2013-09-12 17:45:21 UTC
--gsharedvt=false 

^ the **default** option to share generic value types was turned off.

That means that some generic code will fail at runtime and throw System.ExecutionEngineException. Turning this off saves a bit of space but reduce the usefulness of generics. It should be left at it's default value.
Comment 6 Cesar Giralt 2013-09-12 18:00:34 UTC
Confirmed. By adding --gsharedvt=true to the Additional mtouch arguments I've resolved the issue for our project. Thanks!
Comment 7 Sebastien Pouliot 2013-09-12 18:03:17 UTC
Great! Note that you should be able to set this in your project options UI.

I'm not sure where it is in VS.NET but in XS it's under:

Project Options
- iOS Build
-- Advanced
--- [X] Enable generic value type sharing
Comment 8 Sebastien Pouliot 2013-09-17 08:11:32 UTC
*** Bug 14656 has been marked as a duplicate of this bug. ***