Bug 23909 - Release build application crashing when targeting iOS 8 sdk
Summary: Release build application crashing when targeting iOS 8 sdk
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-10-17 15:02 UTC by Allie Miller
Modified: 2014-11-06 12:20 UTC (History)
4 users (show)

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:

Description Allie Miller 2014-10-17 15:02:50 UTC
After updating iOS application to target iOS 8, the application now crashes during Release deployments to iOS 8 devices.

*Steps to Reproduce*
See private comment regarding test project

*Expected Results*
Application deploys and runs with no issue on iOS 8 devices.

*Actual Results*
Application crashes.

*Additional Information*
The crash did not occur for a few deployments when the "Enable generic value type sharing" option is disabled. However, the crashes eventually resumed. 

Additionally, this may not be specific to Release builds though it was noted that the crash is more reproducible when the debugger is not connected vs. being connected.

*Versioning Information*
=== Xamarin Studio ===

Installation UUID: f6a3c61f-a7e2-4740-ba09-86314760e340
=== Apple Developer Tools ===

Xcode 6.0.1 (6528)
Build 6A317

=== Xamarin.iOS ===


=== Operating System ===

Mac OS X 10.9.5
Darwin Allies-MacBook-Air.local 13.4.0 Darwin Kernel Version 13.4.0
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 3 Rolf Bjarne Kvinge [MSFT] 2014-10-20 05:42:46 UTC
1. The crash report isn't fully symbolicated because the executable doesn't match the project (there's a warning shown during the build). To fix: rename the executable's assembly name to MijnFysioAppMT (in the project's Build/Output page).

2. I tried a Release build on device, it runs into a NullReferenceException and crashes just after inputting a PIN number (I suppose that's what it's asking me for just after putting in the date+pwd at least) twice:

Unhandled managed exception: Object reference not set to an instance of an object (System.NullReferenceException)
at MijnFysioApp.AccountHomeCell.set_TopString (System.String value)
at MijnFysioApp.AccountHomeView+TableViewDataSource.GetCell (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)

3. I also tried a Debug build, and now it starts up. However any of the menu entries report an error: "Deck or type is null."

In any case please get a fully symbolicated crash report first, maybe that'll directly show where the problem is occurring.
Comment 6 Rolf Bjarne Kvinge [MSFT] 2014-10-21 05:18:31 UTC
The crash occurs when you try to remove observers in ViewDeckController.ViewDidDisappear:

12  libsystem_platform.dylib      	0x3231b878 _sigtramp + 40
13  Foundation                    	0x24f27c32 _NSKeyValueReplaceObservationInfoForObject + 54
14  Foundation                    	0x24f27696 -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 326
15  Foundation                    	0x24f271b2 -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 162
16  MijnFysioApp                  	0x001945e8 wrapper_managed_to_native_MonoTouch_ObjCRuntime_Messaging_void_objc_msgSend_IntPtr_IntPtr_intptr_intptr_intptr_intptr + 112
17  MijnFysioApp                  	0x00139288 MonoTouch_Foundation_NSObject_RemoveObserver_MonoTouch_Foundation_NSObject_MonoTouch_Foundation_NSString (NSObject.g.cs:832)
18  MijnFysioApp                  	0x000b4ed0 MijnFysioApp_ViewDeckController_TryRemoveObserver_MonoTouch_Foundation_NSObject_string + 96
19  MijnFysioApp                  	0x000b2a10 MijnFysioApp_ViewDeckController_ViewDidDisappear_bool + 76

I have a few more questions though:

1) What's kind of exceptions are you swallowing in TryRemoveObserver (what's the output of the Console.WriteLine there)?

2) The crash report also mentions an Objective-C exception was thrown (the "Last Exception Backtrace:" part) and information from this exception was most likely printed to the iOS device log, so can you get all the output from the device log (you can view it in Xamarin Studio's menu View -> Pads -> iOS Device Log) and attach it here?
Comment 8 Rolf Bjarne Kvinge [MSFT] 2014-10-21 15:51:11 UTC
It's possible that the crash is a consequence of the Objective-C exception you're getting, so I recommend fixing that problem first. Most likely the crash will go away then.

If the crash still occurs without any Objective-C exceptions being thrown first, please reopen this bug and attach an updated test case.
Comment 10 Rolf Bjarne Kvinge [MSFT] 2014-10-24 06:07:59 UTC
Aidan, you still have the same problem, the only difference is that now the Objective-C exception ends up crashing the app (instead of only getting printed to the device log). As before the device log will contain the exact exception message which should point you to where the KVO problem is. My guess is that you fixed one KVO problem, but you still have more.

Note that Objective-C exceptions in general will crash the app (I don't know why it didn't happen for you earlier).
Comment 12 Rolf Bjarne Kvinge [MSFT] 2014-11-06 12:20:34 UTC
There's a KVO-related exception when a BaseViewController is freed:

Last Exception Backtrace:
0   CoreFoundation                	0x25e6cc1f __exceptionPreprocess + 127
1   libobjc.A.dylib               	0x338e5c8b objc_exception_throw + 38
2   CoreFoundation                	0x25e6cb65 +[NSException raise:format:] + 112
3   Foundation                    	0x26b14c25 NSKVODeallocate + 288
4   MijnFysioAppMT                	0x009b39c8 invoke_objc_method_implementation (monotouch-glue.m:1530)
5   MijnFysioAppMT                	0x009b380c monotouch_release_trampoline (monotouch-glue.m:1559)
6   MijnFysioAppMT                	0x008e111f -[MijnFysioApp_BaseViewController release] (registrar.m:1878)