Bug 13696 - Null reference when linking native code in release mode
Summary: Null reference when linking native code in release mode
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.9.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2013-08-01 16:00 UTC by Christer Nordvik
Modified: 2015-04-17 03:04 UTC (History)
3 users (show)

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

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 Christer Nordvik 2013-08-01 16:00:29 UTC
Not sure but it looks similar to bug #10593. I also have the JSON dll but I got it from here: 
https://components.xamarin.com/gettingstarted/json.net and picked the DLL in the iOS folder. The error started appearing after the latest Mono upgrade with async support. It works fine in the simulator but does not work when compiling for a device. If I after the failure, just hit build all without clean first it actually builds but doesn't work when deploying to the device. It just crashes at startup. 

Let me know what more details you need or if this is a known issue. 


Compiling to native code
/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" --cache "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/obj/iPhone/Release/mtouch-cache" --nomanifest --nosign -dev "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/bin/iPhone/Release/NDC2010.app" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010.Logic/bin/iPhone/Release/NDC2010.Logic.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010.Model/bin/iPhone/Release/NDC2010.Model.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.Linq.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/libs/AlexTouch.Mixberry.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/AdColony.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/MonoTouch.Dialog-1.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/libs/Newtonsoft.Json.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/admob/GoogleAnalytics.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/admob/GoogleAdMobAds.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -sdk "6.1" -targetver "5.1" --abi=armv7+llvm "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/bin/iPhone/Release/NDC2010.exe"
MonoTouch Business version 6.4.0 using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
System.NullReferenceException: Object reference not set to an instance of an object
  at MonoTouch.Tuner.CollectExportedFields+<>c__Iterator4.MoveNext () [0x00000] in <filename unknown>:0 
  at MonoTouch.Application.StripNativeCode () [0x00000] in <filename unknown>:0 
  at MonoTouch.Application.Build () [0x00000] in <filename unknown>:0 
  at MTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0 
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-08-02 07:00:41 UTC
Fixed. The fix will be included in 6.4.2.

As a temporary workaround you can add "-f" to the additional mtouch arguments in the project's iOS Build options page.

monotouch/master-3.0: 6f7b3d7967892ceb71589cfe207ce3d6ce0c9e92
monotouch/monotouch-6.4-series: 2173e66ab230fa14d422436cfe040ec10c9dccf1

The issue with the crash at startup is different, can you file another bug with a test case and crash report for that one?
Comment 2 Christer Nordvik 2013-08-02 07:05:48 UTC
I tested this just now, and I don't see any change. I have the "-f" option and still get the same error: 

Compiling to native code
/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" --cache "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/obj/iPhone/Release/mtouch-cache" --nomanifest --nosign -dev "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/bin/iPhone/Release/NDC2010.app" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010.Logic/bin/iPhone/Release/NDC2010.Logic.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010.Model/bin/iPhone/Release/NDC2010.Model.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.Linq.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/libs/AlexTouch.Mixberry.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/AdColony.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/MonoTouch.Dialog-1.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/libs/Newtonsoft.Json.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/admob/GoogleAnalytics.dll" -r "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/admob/GoogleAdMobAds.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -sdk "6.1" -targetver "5.1" --abi=armv7+llvm "-f" "/Users/cnordvik/projects/private/FotMob/trunk/iPhoneV2/NDC2010/NDC2010/bin/iPhone/Release/NDC2010.exe"
MonoTouch Business version 6.4.0 using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
System.NullReferenceException: Object reference not set to an instance of an object
  at MonoTouch.Tuner.CollectExportedFields+<>c__Iterator4.MoveNext () [0x00000] in <filename unknown>:0 
  at MonoTouch.Application.StripNativeCode () [0x00000] in <filename unknown>:0 
  at MonoTouch.Application.Build () [0x00000] in <filename unknown>:0 
  at MTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0 
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-08-02 07:37:30 UTC
Can you attach your entire project then?
Comment 4 Christer Nordvik 2013-08-02 07:41:10 UTC
All the sourcecode? Or just the binaries? Not sure I want to send the sourcecode since this is our main app which we have based our entire company upon :-)
Comment 5 Rolf Bjarne Kvinge [MSFT] 2013-08-02 07:54:04 UTC
It might be enough if you send me just the dll and exe files referenced in the mtouch command line in comment 2.
Comment 7 Christer Nordvik 2013-08-07 05:59:17 UTC
Did the DLLs help track down the issue? Any hints on how I can track down the issue? Should I remove one by one DLL from the project and see if it is one of the external bindings libraries that causes it?
Comment 8 Rolf Bjarne Kvinge [MSFT] 2013-08-07 10:43:31 UTC
Yes, they did enable me to find the issue.

I don't have a fix yet though, still working on that part.
Comment 9 Christer Nordvik 2013-08-13 07:24:08 UTC
Can we change something on our side to get around the issue? It is a kind of show-stopper for us at the moment since we can't compile for a device.
Comment 10 Christer Nordvik 2013-08-19 05:45:44 UTC
Any updates? We need to push a new bugfix version out very soon and this bug prevents us from doing so. If you can give me the name of the offending DLL then I can maybe remove it from our project as a work-around.
Comment 14 Sebastien Pouliot 2013-09-03 22:31:20 UTC
The original issue is fixed in master c188fec2a8368c4b94a326dd1e4ad54e6241415d

Your last error is a crash in Apple's linker (ld). Those are uncommon and generally hard to diagnose (can't modify Apple's linker). If you can attach all the (latest) binaries into a ZIP file I can confirm it this happens (or hopefully not) with the fix.
Comment 15 Rolf Bjarne Kvinge [MSFT] 2015-04-16 10:27:00 UTC
@Christer, were you able to fix/work around the problem in comment #13?
Comment 16 Christer Nordvik 2015-04-17 03:04:59 UTC
Yes :-)