Bug 33115 - [iOS] Switching view crashes app when using customer binding
Summary: [iOS] Switching view crashes app when using customer binding
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.10
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-08-14 16:32 UTC by Amalia
Modified: 2015-11-18 07:51 UTC (History)
7 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 Amalia 2015-08-14 16:32:46 UTC
### Overview

The customer used the command line tool to create a Xamarin Binding of their framework. When the app using the binding is run, it crashes when the NChart3D view is not used anymore.

The application output when the app first loads shows: "Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn"

The application output around the crash shows this error: "Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application."

### Steps to reproduce

1) Download and run the customer's app (in comment 1)

2) Click "Show chart"

3) Click the "Root View Controller" back arrow

### Expected results

App doesn't crash

### Actual results

App crashes with SIGSEGV

### Additional information

Customer's binding project and a sample of the bits they're trying to bind in comment 1

Version info:
=== Xamarin Studio ===

Version 5.9.5 (build 9)
Installation UUID: 1f52eea2-a387-4a2c-96c1-4637c8f8567a
	Mono 4.0.3 ((detached/d6946b4)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400030020

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: 2c66d2f
Branch: master
Build date: 2015-08-04 13:52:25-0400

=== Xamarin.Android ===

Version: (Enterprise Edition)
Android SDK: /Users/amalias/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: (Enterprise Edition)

=== Build Information ===

Release ID: 509050009
Git revision: b99cb19a1d3b15d8980c4616f13f837457e5b292
Build date: 2015-07-28 02:01:44-04
Xamarin addins: d53d6eceb828422f3d4aff8547f2f6bab6c9ea58

=== Operating System ===

Mac OS X 10.10.4
Darwin amalias.local 14.4.0 Darwin Kernel Version 14.4.0
    Thu May 28 11:35:04 PDT 2015
    root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-09-01 06:17:27 UTC
This looks like the NChart3D component is depending on a specific release order and if objects are released in an unexpected order, then the crash occurs. This is problematic for Xamarin.iOS, since the GC will free objects in any order.

Fortunately there seems to be an easy workaround: force native objects to be freed in a specific order. Simply adding this line to ViewDidDisappear (before the call to RemoveFromSuperView) seems to fix the crash:

> chartView.Chart.Dispose ();