Bug 53435 - Crash on Xamarin.iOS in MethodCallExpression when using AutoMapper / Linq
Summary: Crash on Xamarin.iOS in MethodCallExpression when using AutoMapper / Linq
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 10.4 (C9)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 15.2
Assignee: Marek Safar
Depends on:
Reported: 2017-03-17 09:17 UTC by Christophe C
Modified: 2017-04-18 08:08 UTC (History)
5 users (show)

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

The place where I get the exception (94.66 KB, image/png)
2017-03-17 09:17 UTC, Christophe C

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 Christophe C 2017-03-17 09:17:03 UTC
Created attachment 20404 [details]
The place where I get the exception


I have a strange crash on Xamarin.iOS (not Xamarin.Droid) when I use Automapper.

Here the crash details from Xamarin Studio:

System.ArgumentNullException: Value cannot be null.
Parameter name: method
  at System.Linq.Expressions.Expression.Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Collections.Generic.IEnumerable`1[T] arguments) [0x00036] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Linq.Expressions.Expression.Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Linq.Expressions.Expression[] arguments) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at Microsoft.Scripting.Interpreter.LoopCompiler.VisitGoto (System.Linq.Expressions.GotoExpression node) [0x000b5] in <8ca03335324246d9910f8060b3fecce2>:0
  at System.Linq.Expressions.GotoExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Linq.Expressions.ExpressionVisitor.VisitConditional (System.Linq.Expressions.ConditionalExpression node) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Linq.Expressions.ConditionalExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Linq.Expressions.ExpressionVisitor.VisitLoop (System.Linq.Expressions.LoopExpression node) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Linq.Expressions.LoopExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at Microsoft.Scripting.Interpreter.LoopCompiler.CreateDelegate () [0x00000] in <8ca03335324246d9910f8060b3fecce2>:0
  at Microsoft.Scripting.Interpreter.EnterLoopInstruction.Compile (System.Object frameObj) [0x00074] in <8ca03335324246d9910f8060b3fecce2>:0
  at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
  at ObjCRuntime.Runtime.ThreadPoolDispatcher (System.Func`1[TResult] callback) [0x00006] in /Users/builder/data/lanes/3985/ba11e481/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:231
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/

This exception is in the method public static MethodCallExpression Call(Expression instance, MethodInfo method, IEnumerable<Expression> arguments) line 798 in the class Xamarin.iOS.framework/Versions/

I can reproduce this crash when I use Automapper. Just call this kind if method 10 times (exactly 10 times):

var result = Mapper.Map<ShipmentDetails>(shipmentDetailsBindingModel);

- I have a single instance of Mapper. I'm using Autofac and get the instance like this : private IMapper Mapper => ServiceLocator.Current.GetInstance<IMapper>();
- Systemn.Linq version: 4.3.0
- Systemn.Linq.Expressions version: 4.3.0
- Systemn.Linq.Queryable version: 4.3.0
- Automapper 5.2.0 (6.0.0 available)
- Autofac 4.2.0 (4.4.0 available)

=== Xamarin Studio Community ===

Version 6.2 (build 1829)
Installation UUID: 8282529d-bb93-4256-b39f-304b5c5c248c
	Mono 4.8.0 (mono-4.8.0-branch/e4a3cf3) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000495

=== NuGet ===

Version :

=== Xamarin.Profiler ===

Version : 1.2.1
Emplacement : /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.iOS ===

Version: (Xamarin Studio Community)
Hash: ba11e48
Branch: cycle9
Build date: 2017-03-10 08:48:04-0500

=== Xamarin.Android ===

Non installé

=== Xamarin Android Player ===

Non installé

=== Xamarin.Mac ===

Not Installed

=== Xamarin Inspector ===

Hash: cdc01b9
Branch: 1.1-release
Build date: Wed, 22 Feb 2017 23:24:11 GMT

=== Build Information ===

Release ID: 602001829
Git revision: 3a28108feb03a6384702c96ffc8c548121cdf37c
Build date: 2017-03-12 06:55:23-04
Xamarin addins: 295d27f8dcdde049a1807a76c888fc0a6557357d
Build lane: monodevelop-lion-cycle9

=== Operating System ===

Mac OS X 10.12.3
Darwin Mac-mini-de-Christophe.local 16.4.0 Darwin Kernel Version 16.4.0
    Thu Dec 22 22:53:21 PST 2016
    root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Redth's Addins 1.0.6
JSON Copy 1.1

Thank you for your support.
Best regards.
Comment 1 Marek Safar 2017-03-17 11:12:39 UTC
It should be fixed in upcoming 15.2 release
Comment 2 Christophe C 2017-03-17 12:17:58 UTC
Thank you for your quick reply !

But I have a question: What is the 15.2 release ? Do you know when it will be released ? (Approximatively) 

Thank you so much.
Best regards,

Comment 3 Marek Safar 2017-03-20 22:28:48 UTC
It should be in preview at the beginning of next month
Comment 4 Swati Gangrade 2017-04-14 06:46:07 UTC
@Christophe C : Can u please retest this issue as bug repro steps are missning
Comment 5 Christophe C 2017-04-18 08:08:07 UTC

I tried to reproduce this crash and it seems to be fixed ! I can't reproduce it anymore with the Alpha Release (15.2).

Thank you so much guys !