Bug 57124 - MTOUCH : error MT2102: Error processing the method 'System.Boolean Couchbase.Lite.Storage.SystemSQLite.SqliteCouchStore/<GetDocNumericID>c__AnonStorey6::<>m__0(Couchbase.Lite.Cursor)' in the assembly 'Couchbase.Lite.Storage.SystemSQLite.dll'
Summary: MTOUCH : error MT2102: Error processing the method 'System.Boolean Couchbase....
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 10.12 (d15-3)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-06-02 23:52 UTC by Andy
Modified: 2017-07-28 15:42 UTC (History)
6 users (show)

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


Attachments
diagnostic build log (930.10 KB, text/plain)
2017-06-02 23:52 UTC, Andy
Details
Example project (19.53 KB, application/zip)
2017-06-07 13:42 UTC, Andy
Details
dll and mdb requested (70.71 KB, application/zip)
2017-07-12 22:23 UTC, Andy
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 ANSWERED

Description Andy 2017-06-02 23:52:09 UTC
Created attachment 22666 [details]
diagnostic build log

The compilation works in other versions of Xamarin, but in the latest xamarin-macios master, it fails to compile when adding the Couchbase.Lite package. This does not require an app extension, although my branch does have an app extension because it was originally made for another purpose. Here is a link to a project which has the issue.
https://github.com/zippo227/ios-samples/tree/master/ios10/MessageCodeSharing

You actually won't see this error because of another error in xamarin-macios which I've fixed in my fork. https://github.com/xamarin/xamarin-macios/pull/2171

--EXCEPTION

/Users/andymartin/Code/ios-samples/ios10/MessageCodeSharing/MessageCodeSharing/obj/iPhone/Release/mtouch-cache/64/PreBuild using mode 'SDKOnly'
    MTOUCH : error MT2102: Error processing the method 'System.Boolean Couchbase.Lite.Storage.SystemSQLite.SqliteCouchStore/<GetDocNumericID>c__AnonStorey6::<>m__0(Couchbase.Lite.Cursor)' in the assembly 'Couchbase.Lite.Storage.SystemSQLite.dll': Value cannot be null.
    Parameter name: instruction
    	Error processing method: 'System.Boolean Couchbase.Lite.Storage.SystemSQLite.SqliteCouchStore/<GetDocNumericID>c__AnonStorey6::<>m__0(Couchbase.Lite.Cursor)' in assembly: 'Couchbase.Lite.Storage.SystemSQLite.dll'
    	Value cannot be null.
    Parameter name: instruction
      at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[Mono.Cecil.AssemblyDefinition]& assemblies) [0x00145] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/Tuning.cs:94 
      at Xamarin.Bundler.Target.LinkAssemblies (System.Collections.Generic.List`1[Mono.Cecil.AssemblyDefinition]& assemblies, System.String output_dir, System.Collections.Generic.IEnumerable`1[T] sharedCodeTargets) [0x0029a] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/Target.cs:491 
      at Xamarin.Bundler.Target.ManagedLink () [0x005c5] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/Target.cs:614 
      at Xamarin.Bundler.Target.ProcessAssemblies () [0x000bb] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/Target.cs:800 
      at Xamarin.Bundler.Application.ProcessAssemblies () [0x0002f] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/Application.cs:1396 
      at Xamarin.Bundler.Application.BuildManaged () [0x00001] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/Application.cs:827 
      at Xamarin.Bundler.Application+<>c.<BuildAll>b__134_1 (Xamarin.Bundler.Application v) [0x00000] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/Application.cs:775 
      at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00024] in <400071ddcfe64ed8a3531490bb763536>:0 
      at Xamarin.Bundler.Application.BuildAll () [0x00050] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/Application.cs:775 
      at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x00481] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/mtouch.cs:1420 
      at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000f] in /Users/andymartin/Code/xamarin-macios/tools/mtouch/mtouch.cs:945 
    The command exited with code 1.
  Done executing task "MTouch" -- FAILED.
Done building target "_CompileToNative" in project "MessageCodeSharing.csproj" -- FAILED.

--DETAILS

Visual Studio Community 2017 for Mac (Preview)
Version 7.1 Preview (7.1 build 583)
Installation UUID: 80b8f93e-f9ea-42b6-9ca5-f0bf2935d27e
Runtime:
	Mono 5.2.0.104 (2017-04/4a0006f) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 502000104

NuGet
Version: 4.0.0.2323

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
SDK: /usr/local/share/dotnet/sdk/1.0.3/Sdks
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

Xamarin.Profiler
'/Applications/Xamarin Profiler.app' not found

Xamarin.Android
Version: 7.3.1.2 (Visual Studio Community)
Android SDK: /Users/andymartin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.3   (API level 18)
		4.4   (API level 19)
		5.1   (API level 22)
		6.0   (API level 23)
		7.0   (API level 24)
		7.1   (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.6
SDK Build Tools Version: 25.0.3

Java SDK: /usr
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Apple Developer Tools
Xcode 8.3.2 (12175)
Build 8E2002

Xamarin.iOS
Version: 10.11.1.77 (Visual Studio Community)
Hash: d6b0d4c
Branch: master
Build date: 2017-06-02 18:23:39-0500

Xamarin.Mac
Version: 3.5.1.82 (Visual Studio Community)

Xamarin Inspector
Version: 1.3.0-alpha2
Hash: fa030e0
Branch: master
Build date: Thu, 01 Jun 2017 20:55:26 GMT
Client compatibility: 1

Build Information
Release ID: 701000583
Git revision: 445a7f09feca58babb966e0c66a6b299d0bd450c
Build date: 2017-05-12 16:05:38-04
Xamarin addins: f9b72ca5f6ca5d9476d8f58353ada2afd56c549b
Build lane: monodevelop-lion-d15-3-preview

Operating System
Mac OS X 10.12.5
Darwin 16.6.0 Darwin Kernel Version 16.6.0
    Fri Apr 14 16:21:16 PDT 2017
    root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
Comment 1 Andy 2017-06-02 23:55:18 UTC
I believe the issue is related to a bug in the linker.
Comment 2 Andy 2017-06-03 00:15:13 UTC
It is able to compile with xamarin.ios-10.11.1.60  . I might investigate further to see exactly which version broke it.
Comment 3 Andy 2017-06-03 17:35:27 UTC
It was requested that I split my pull request into two. The pull request with the exception fix is now https://github.com/xamarin/xamarin-macios/pull/2172
Comment 4 Manuel de la Peña [MSFT] 2017-06-05 09:29:03 UTC
Setting the bug to fixed so that QA will pick it up. PR was merged.
Comment 5 Andy 2017-06-05 11:19:31 UTC
Actually the fix I put in was just so that you could see the exception that was thrown. The primary bug is still a problem.
Comment 6 Andy 2017-06-05 16:39:12 UTC
It was broken by this pull request: https://github.com/xamarin/xamarin-macios/commit/51cda3b468b399107459bb63e35221bd5eb89367
Comment 7 Andy 2017-06-05 18:35:48 UTC
Actually, I think that it maybe have been broken by this update which bumped mono. https://github.com/xamarin/xamarin-macios/commit/56e36921ddd8d0065787be4f7f823ee2fd9129cb
Comment 8 Manuel de la Peña [MSFT] 2017-06-06 16:02:40 UTC
Ok, then we need to reopen the bug.
Comment 9 Manuel de la Peña [MSFT] 2017-06-07 09:52:24 UTC
@Andy could we get a sample to use with the bug for testing?
Comment 10 Andy 2017-06-07 13:17:43 UTC
https://github.com/zippo227/ios-samples/tree/master/ios10/MessageCodeSharing   Build this project in Release mode, or any configuration with linking enabled. Use any xamarin.ios version 10.11.1.66 or above.
Comment 11 Andy 2017-06-07 13:42:51 UTC
Created attachment 22744 [details]
Example project

Build using Debug|iPhone, Release|iPhone Simulator, or Release|iPhone using https://bosstoragemirror.azureedge.net/wrench/macios-mac-master/51/51cda3b468b399107459bb63e35221bd5eb89367/xamarin.ios-10.11.1.66.pkg
Comment 12 Rolf Bjarne Kvinge [MSFT] 2017-06-15 10:20:14 UTC
Reopening since a sample was provided.
Comment 13 Andy 2017-06-22 20:41:42 UTC
Are there any updates on this issue?
Comment 14 Manuel de la Peña [MSFT] 2017-06-27 15:58:35 UTC
Hello,

I have been testing the application with the following setup:

=== Visual Studio Enterprise 2017 for Mac (Preview) ===

Version Preview - Internal Dogfood (7.1 build 1258)
Installation UUID: 8d12e55e-3489-463f-ac52-8cb4573c5a81
Runtime:
	Mono 5.2.0.179 (2017-04/4498dc4) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 502000179

=== NuGet ===

Version: 4.3.0.2418

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 1.0.0
SDK: /usr/local/share/dotnet/sdk/1.0.0-preview2-003121/Sdks
SDK Version: 1.0.0-preview2-003121
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.3 (12169)
Build 8E162

=== Xamarin.iOS ===

Version: 10.13.0.20 (Visual Studio Enterprise)
Hash: 8c55dd88
Branch: master
Build date: 2017-06-27 11:20:06+0200

=== Xamarin.Android ===

Version: 7.3.1.2 (Visual Studio Enterprise)
Android SDK: /Users/mandel/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		6.0   (API level 23)
		7.1   (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.4
SDK Build Tools Version: 25.0.1

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin.Mac ===

Version: 3.7.0.20 (Visual Studio Enterprise)

=== Xamarin Inspector ===

Version: 1.3.0-alpha2
Hash: fa030e0
Branch: master
Build date: Thu, 01 Jun 2017 20:55:26 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 701001258
Git revision: b0333c272ef55159b4c209e71698203d2fb4acdd
Build date: 2017-06-26 17:46:52-04
Xamarin addins: 31cc58bd6e356d0e68b4dd5c9b51283f1506ce99
Build lane: monodevelop-lion-dogfood-vNext

=== Operating System ===

Mac OS X 10.12.5
Darwin 16.6.0 Darwin Kernel Version 16.6.0
    Fri Apr 14 16:21:16 PDT 2017
    root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

With the above setup the application does compile and does not crash (this is in master) so I believe the issue is fixed in master.
Comment 15 Andy 2017-06-27 16:24:41 UTC
I just tested it with the latest Master 10.13.0.47 and am still getting the issue.

You have to be using a configuration that is at least set to Link SDK Assemblies. Which configuration were you using?

If you try to build in Debug | iPhone, the error remains. Release | iPhone Simulator is erroneously set to Don't Link. I apologize for that if that was the configuration you were using.

Visual Studio Community 2017 for Mac (Preview)
Version 7.1 Preview (7.1 build 583)
Installation UUID: 80b8f93e-f9ea-42b6-9ca5-f0bf2935d27e
Runtime:
	Mono 5.2.0.104 (2017-04/4a0006f) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 502000104

NuGet
Version: 4.0.0.2323

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
SDK: /usr/local/share/dotnet/sdk/1.0.3/Sdks
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

Xamarin.Profiler
Version: 1.5.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Xamarin.Android
Version: 7.3.1.2 (Visual Studio Community)
Android SDK: /Users/andymartin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.3   (API level 18)
		4.4   (API level 19)
		5.1   (API level 22)
		6.0   (API level 23)
		7.0   (API level 24)
		7.1   (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.6
SDK Build Tools Version: 25.0.3

Java SDK: /usr
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Apple Developer Tools
Xcode 8.3.2 (12175)
Build 8E2002

Xamarin.iOS
Version: 10.13.0.47 (Visual Studio Community)
Hash: 1c7b9e1d
Branch: mono-2017-06
Build date: 2017-06-26 17:02:46-0400

Xamarin.Mac
Version: 3.5.0.126 (Visual Studio Community)

Xamarin Inspector
Version: 1.3.0-alpha2
Hash: fa030e0
Branch: master
Build date: Thu, 01 Jun 2017 20:55:26 GMT
Client compatibility: 1

Build Information
Release ID: 701000583
Git revision: 445a7f09feca58babb966e0c66a6b299d0bd450c
Build date: 2017-05-12 16:05:38-04
Xamarin addins: f9b72ca5f6ca5d9476d8f58353ada2afd56c549b
Build lane: monodevelop-lion-d15-3-preview

Operating System
Mac OS X 10.12.5
Darwin 16.6.0 Darwin Kernel Version 16.6.0
    Fri Apr 14 16:21:16 PDT 2017
    root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
Comment 16 Andy 2017-06-27 19:05:22 UTC
It appears to be related to this change : https://github.com/jbevain/cecil/commit/7c8e0f767d7b2f652a430e4e26f1d98a20f9e125

The start_instruction returns null.
Comment 17 Andy 2017-07-07 22:23:57 UTC
Cross linking this here for the Couchbase.Lite team. https://github.com/couchbase/couchbase-lite-net/issues/888
Comment 18 Manuel de la Peña [MSFT] 2017-07-10 08:43:31 UTC
@Andy can you please let me know why do you point to that commit? We can try and pick a version of cecil without that change and re-test.
Comment 19 Sebastien Pouliot 2017-07-10 13:44:29 UTC
c.c. JB for Cecil

@Manuel let's start confirming the bug can be duplicated and update its data.
Comment 20 Andy 2017-07-10 15:31:22 UTC
@Manuel, Through hours of checking through commits, that change seems to be what started the issue.  Yes, I agree with @Sebastian that it would be good to first CONFIRM the bug. Just make sure to build the example solution in Debug | iPhone where Link SDK Assemblies is enabled. https://github.com/zippo227/ios-samples/tree/master/ios10/MessageCodeSharing
Comment 21 Jb Evain 2017-07-12 22:13:59 UTC
If the issue is caused by https://github.com/jbevain/cecil/commit/7c8e0f767d7b2f652a430e4e26f1d98a20f9e125

It's usually a symptom that the debug symbols are out of sync with the assembly.

Could you attach the dll+pdb passed to the linker? I'll look into it.
Comment 22 Andy 2017-07-12 22:23:17 UTC
Created attachment 23508 [details]
dll and mdb requested

@jbevain, here is the dll and mdb
Comment 23 Andy 2017-07-17 18:25:02 UTC
any updates on this issue?
Comment 24 Jb Evain 2017-07-18 17:44:09 UTC
As far as I can tell, it's another case of the mdb being out of sync with the dll.
Comment 25 Jb Evain 2017-07-18 18:11:54 UTC
Here's what mdbdump gives me for the offending method:

    <method token="0x60000b4" signature="System.Boolean Couchbase.Lite.Storage.SystemSQLite.SqliteCouchStore/&lt;GetDocNumericID&gt;c__AnonStorey6::&lt;&gt;m__0(Couchbase.Lite.Cursor)">
      <sequencepoints>
        <entry il="0x0" row="146" col="13" file_ref="8" />
        <entry il="0xb" row="147" col="17" file_ref="8" />
        <entry il="0xd" row="149" col="13" file_ref="8" />
        <entry il="0x14" row="150" col="13" file_ref="8" />
        <entry il="0x1b" row="151" col="13" file_ref="8" />
        <entry il="0x23" row="152" col="13" file_ref="8" />
        <entry il="0x33" row="156" col="17" file_ref="8" />
        <entry il="0x3f" row="157" col="17" file_ref="8" />
        <entry il="0x50" row="158" col="54" file_ref="8" />
        <entry il="0x69" row="158" col="30" file_ref="8" />
        <entry il="0x6d" row="159" col="25" file_ref="8" />
        <entry il="0x7b" row="158" col="54" file_ref="8" />
        <entry il="0x88" row="163" col="17" file_ref="8" />
        <entry il="0xbd" row="164" col="15" file_ref="8" />
        <entry il="0xc3" row="165" col="17" file_ref="8" />
        <entry il="0xdc" row="166" col="17" file_ref="8" />
        <entry il="0xde" row="167" col="15" file_ref="8" />
        <entry il="0xdf" row="168" col="17" file_ref="8" />
        <entry il="0xfa" row="171" col="13" file_ref="8" />
      </sequencepoints>
      <locals>
        <entry name="statement" il_index="0" scope_ref="3" />
        <entry name="ex" il_index="3" scope_ref="7" />
      </locals>
      <scopes>
        <entry index="0" start="0x33" end="0xbd" />
        <entry index="1" start="0x50" end="0x88" />
        <entry index="2" start="0x50" end="0x88" />
        <entry index="3" start="0x69" end="0x7b" />
        <entry index="4" start="0x6d" end="0x7b" />
        <entry index="5" start="0xc3" end="0xde" />
        <entry index="6" start="0xde" end="0xfa" />
      </scopes>
    </method>

Which doesn't seem to match it's IL body.
Comment 26 Jb Evain 2017-07-18 20:39:27 UTC
Given the build log, I don't think this is xamlc issue, and it might be the case that the Couchbase nuget ships a broken mdb.
Comment 27 John Miller [MSFT] 2017-07-26 14:49:55 UTC
@Andy

While reviewing this bug I did notice that I am not able to reproduce an issue building with version 10.12.0.14 of Xamarin.iOS (currently beta). Can you confirm if this resolves the build issue for you?
Comment 28 Andy 2017-07-26 16:53:25 UTC
@John, sadly no, it does not resolve the build issue.

You have to build in Debug - Device (not simulator) where link sdk assemblies is enabled. If you build in Release mode device, you get a different issue, "Error MT2091: Inliner failed processing `System.Boolean Couchbase.Lite.Storage.SystemSQLite.SqliteCouchStore/<GetDocNumericID>c__AnonStorey6::<>m__0(Couchbase.Lite.Cursor)`. (MT2091) (MessageCodeSharing)"
Comment 29 Andy 2017-07-28 15:42:35 UTC
I've confirmed that building Couchbase.Lite and the Couchbase.Lite.SystemSQLite from scratch fixed the issue. This is an issue with Couchbase now, not Xamarin. Thank you.