This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 58834 - "Error processing the method 'System.Void ...' Value cannot be null." due to ArgumentNullException for `instruction` parameter in Mono.Linker's `MarkException()` method when a referenced assembly has problematic debug symbols, for example "Couchbase.Lite"
Summary: "Error processing the method 'System.Void ...' Value cannot be null." due to ...
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: XI 10.12 (d15-3)
Hardware: PC Mac OS
: Highest blocker
Target Milestone: 15.3
Assignee: Sebastien Pouliot
URL:
: 58791 58813 58835 (view as bug list)
Depends on: 58789 58813
Blocks: 58835
  Show dependency tree
 
Reported: 2017-08-17 03:40 UTC by Brendan Zagaeski (Xamarin Support)
Modified: 2017-09-05 10:55 UTC (History)
10 users (show)

See Also:
Tags:
Is this bug a regression?: Yes
Last known good build: Xamarin.iOS 10.10.0.33 (d15-2: 3e5ac5ff)


Attachments
Test case (10.39 KB, application/zip)
2017-08-17 03:40 UTC, Brendan Zagaeski (Xamarin Support)
Details
Diagnostic build output, detailed version info (72.35 KB, application/zip)
2017-08-17 03:41 UTC, Brendan Zagaeski (Xamarin Support)
Details

Description Brendan Zagaeski (Xamarin Support) 2017-08-17 03:40:46 UTC
Created attachment 24259 [details]
Test case

"Error processing the method 'System.Void ...' Value cannot be null." due to ArgumentNullException for `instruction` parameter in Mono.Linker's `MarkException()` method when a referenced assembly has problematic debug symbols, for example "Couchbase.Lite"




## Partial workaround

As theorized in Bug 58789, Comment 24, deleting the debug symbols for the problematic assembly ("packages/Couchbase.Lite.1.4.0/lib/Xamarin.iOS10/Couchbase.Lite.dll.mdb" in this test case) does indeed allow the build to complete successfully.




## Regression status: regression in Xamarin.iOS 10.12.0.18 (d15-3: 4a279c9a)

BAD:  Xamarin.iOS            (master: a001cace)*
BAD:  Xamarin.iOS 10.12.0.18 (d15-3: 4a279c9a)
GOOD: Xamarin.iOS 10.10.0.33 (d15-2: 3e5ac5ff)

[*] Unpublished CI build from the "master" development branch. (This suggests that the issue is distinct from Bug 57645.)




## Steps followed to test


1. Open the attached test case in Visual Studio for Mac to restore the NuGet packages. (This is a from-scratch test case generated from a template project by adding a couple Couchbase NuGet packages.) 


2. Attempt to build the project in the Debug|iPhone configuration:

msbuild /t:Build /p:Configuration=Debug /p:Platform=iPhone SingleViewIphone1.sln




## BAD Results with Xamarin.iOS 10.12.0.18 (d15-3: 4a279c9a) plus the `mtouch` binary from Bug 58789, Comment 4

The build fails with an exception about a null value for the `instruction` parameter.  Top of the exception call stack from the diagnostic build output with `-v -v -v -v` `mtouch` logging:

> MTOUCH : error MT2102: Error processing the method 'System.Void Couchbase.Lite.Auth.OpenIDAuthenticator/<ContinueAsyncLogin>c__AnonStorey0::<>m__0()' in the assembly 'Couchbase.Lite.dll': Value cannot be null. [/Users/Shared/Projects/CouchbaseLiteLinking/SingleViewIphone1/SingleViewIphone1.csproj]
>   Parameter name: instruction (TaskId:64)
>   --- inner exception (TaskId:64)
>   Mono.Linker.MarkException: Error processing method: 'System.Void Couchbase.Lite.Auth.OpenIDAuthenticator/<ContinueAsyncLogin>c__AnonStorey0::<>m__0()' in assembly: 'Couchbase.Lite.dll' ---> System.ArgumentNullException: Value cannot be null. (TaskId:64)
>   Parameter name: instruction (TaskId:64)
>     at Mono.Cecil.Cil.InstructionOffset..ctor (Mono.Cecil.Cil.Instruction instruction) [0x00003] in <311724b4987d46ff81eafbc5bdc70a4e>:0  (TaskId:64)
>     at Mono.Cecil.Cil.CodeReader.ReadScope (Mono.Cecil.Cil.ScopeDebugInformation scope) [0x00015] in <311724b4987d46ff81eafbc5bdc70a4e>:0  (TaskId:64)
>     at Mono.Cecil.Cil.CodeReader.ReadScopes (Mono.Collections.Generic.Collection`1[T] scopes) [0x0000c] in <311724b4987d46ff81eafbc5bdc70a4e>:0  (TaskId:64)
>     at Mono.Cecil.Cil.CodeReader.ReadScope (Mono.Cecil.Cil.ScopeDebugInformation scope) [0x000af] in <311724b4987d46ff81eafbc5bdc70a4e>:0  (TaskId:64)
>     at Mono.Cecil.Cil.CodeReader.ReadDebugInfo () [0x0002a] in <311724b4987d46ff81eafbc5bdc70a4e>:0  (TaskId:64)
>     at Mono.Cecil.Cil.CodeReader.ReadMethodBody () [0x00091] in <311724b4987d46ff81eafbc5bdc70a4e>:0  (TaskId:64)
>     at Mono.Cecil.Cil.CodeReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00014] in <311724b4987d46ff81eafbc5bdc70a4e>:0  (TaskId:64)
>     at Mono.Cecil.MetadataReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00000] in <311724b4987d46ff81eafbc5bdc70a4e>:0  (TaskId:64)



## BAD Results with Xamarin.iOS 10.12.0.18 (d15-3: 4a279c9a)

The build fails with the non-descriptive "error MT0000: Unexpected error" as per Bug 58789.




## GOOD Results with Xamarin.iOS 10.10.0.33 (d15-2: 3e5ac5ff)

The build completes without error.




## Additional testing environment info (brief)

Mono 5.2.0.215 (d15-3/da80840) (64-bit)

Xcode 8.3 (12169), Build 8E162
macOS 10.12.6
US English locale, US Eastern time zone
Comment 1 Brendan Zagaeski (Xamarin Support) 2017-08-17 03:41:40 UTC
Created attachment 24260 [details]
Diagnostic build output, detailed version info
Comment 2 Brendan Zagaeski (Xamarin Support) 2017-08-17 04:33:21 UTC
## Bookkeeping note (to the Xamarin team)

This bug is primarily intended to provide a concrete simple test case for the various testing scenarios where having a concrete simple test case might be helpful during the investigation and retrospective analysis of the set of user-submitted issues about (probably) the same error such as Bug 58813 and several of the comments on Bug 58789.
Comment 3 Sebastien Pouliot 2017-08-17 18:21:51 UTC
Thanks! I can duplicate the issue locally.
Comment 4 Sebastien Pouliot 2017-08-17 18:57:07 UTC
The exception occurs on

`System.Void Couchbase.Lite.Auth.OpenIDAuthenticator/<ContinueAsyncLogin>c__AnonStorey0::<>m__0()`


And this does _not_ happen with d15-2 but it does in d15-3, which means the .pdb itself is not the (only*) issue.

* it could be incorrect, e.g. new validations, but it was good enough before


c.c. JB and Marek since this might be related to a recent Cecil change (or mono's fork).
Comment 5 Brendan Zagaeski (Xamarin Support) 2017-08-17 20:18:34 UTC
## Additional cross-references (for the Mono.Cecil team)

Similar errors have been reported earlier on Xamarin.Android:

Non-public Bug 57675
Bug 58711

I suppose there's at least a chance that the Mono.Cecil fix from non-public Bug 57675 [1] was not bumped into the d15-4 branch of Xamarin.Android (explaining Bug 58711) and not bumped into Xamarin.iOS (potentially explaining this Bug 58834)?

[1] https://github.com/mono/cecil/commit/16d23978e7084c910b47f84092a5c546d880ae48
Comment 6 Sebastien Pouliot 2017-08-17 20:26:13 UTC
The issue does not happen if I switch from external/mono/external/cecil (the submodule of mono/2017-04) to external/linker/cecil

There are too many roads to Cecil today
Comment 7 Sebastien Pouliot 2017-08-18 02:16:24 UTC
PR for mono/2017-04 https://github.com/mono/mono/pull/5399
PR for mono/d15-3 https://github.com/mono/mono/pull/5400

Once merged bump PR for xamarin-macios will pick them up.

Awaiting a more global/permanent solution for master...
Comment 9 Vincent Dondain [MSFT] 2017-08-18 19:45:39 UTC
*** Bug 58835 has been marked as a duplicate of this bug. ***
Comment 11 Brendan Zagaeski (Xamarin Support) 2017-08-18 23:35:25 UTC
## Experimental installer package available

The following experimental quality installer package includes the candidate fix for this issue.  Be advised that this package has not been through any QA testing, but it did successfully stop the problem in my local tests for the scenario described in Comment 0 (both in Visual Studio for Mac and in Visual Studio 2017 on Windows).

Download the following package onto your Mac and double-click it in Finder to run the installer:
https://dl.xamarin.com/uploads/0kukur04kni/xamarin.ios-10.12.0.20.pkg

Because this is an experimental version installed outside of the updater channels mechanism, Visual Studio for Mac will continue to offer an "update" back to the _older_ published Stable updater channel versions when you have this version installed.  You will need to ignore that notification if you wish to keep using this experimental version.




## Steps to switch back to the current published version

If any users need to switch back to the current published version Xamarin.iOS 10.12.0.18 after trying this experimental version, you can do so using either of the following methods:

- Check for updates on the Stable updater channel within Visual Studio for Mac on your Mac.  At the moment, this will offer you the original 10.12.0.18 version of Xamarin.iOS.  (Note that in the near future, after additional testing and approvals, the candidate fixes will also be published to the Stable updater channel.)

OR

- Manually download and run the individual older Xamarin.iOS installer package as described on https://kb.xamarin.com/customer/portal/articles/1699777-older-downloads.
Comment 12 Sebastien Pouliot 2017-08-21 13:22:16 UTC
*** Bug 58791 has been marked as a duplicate of this bug. ***
Comment 16 Brendan Zagaeski (Xamarin Support) 2017-08-22 22:25:41 UTC Comment hidden (obsolete)
Comment 17 Brendan Zagaeski (Xamarin Support) 2017-08-22 22:27:53 UTC
## Status update for any users watching this issue

The candidate fix for this issue has now been published to the Stable and Beta updater channels as part of Xamarin.iOS 10.12.0.20 in the Xamarin 15.3.2 Servicing Release [1].

[1] https://releases.xamarin.com/stable-release-15-3-2/
Comment 18 Brendan Zagaeski (Xamarin Support) 2017-08-24 15:50:08 UTC
*** Bug 58813 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.