Bug 35457 - SIGSEGV when adding too many MKAnnotations to a MKMapView
Summary: SIGSEGV when adding too many MKAnnotations to a MKMapView
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: XI 9.1 (iOS 9.1)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-11-02 08:19 UTC by Adam Hartley [MSFT]
Modified: 2015-12-03 17:20 UTC (History)
4 users (show)

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


Attachments
Sample (982.58 KB, application/zip)
2015-11-02 08:19 UTC, Adam Hartley [MSFT]
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 Adam Hartley [MSFT] 2015-11-02 08:19:01 UTC
Created attachment 13613 [details]
Sample

## Steps to reproduce

1. Download attached sample
2. Run on the Simulator (8.4 and 9.1 were tested)
3. Tap the "All" button multiple times (between 15 and 20 times on average)

## Expected result

No crash

## Actual result

App crashes with the following stack trace:

2015-11-02 13:12:06.294 MapCallouts[3198:218564] critical: Stacktrace:

2015-11-02 13:12:06.299 MapCallouts[3198:218564] critical:   at <unknown> <0xffffffff>
2015-11-02 13:12:06.300 MapCallouts[3198:218564] critical:   at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (intptr,intptr,intptr) <IL 0x0002d, 0xffffffff>
2015-11-02 13:12:06.301 MapCallouts[3198:218564] critical:   at MapKit.MKMapView.AddAnnotation (MapKit.IMKAnnotation) [0x00021] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/build/ios/native/MapKit/MKMapView.g.cs:105
2015-11-02 13:12:06.302 MapCallouts[3198:218564] critical:   at MapCallouts.MainViewController.allAction (Foundation.NSObject) [0x000b8] in /Users/Adam/Downloads/Callout/MainViewController.cs:96
2015-11-02 13:12:06.302 MapCallouts[3198:218564] critical:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <IL 0x00062, 0xffffffff>
2015-11-02 13:12:06.302 MapCallouts[3198:218564] critical:   at <unknown> <0xffffffff>
2015-11-02 13:12:06.302 MapCallouts[3198:218564] critical:   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x000ae, 0xffffffff>
2015-11-02 13:12:06.303 MapCallouts[3198:218564] critical:   at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIApplication.cs:77
2015-11-02 13:12:06.304 MapCallouts[3198:218564] critical:   at UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIApplication.cs:61
2015-11-02 13:12:06.304 MapCallouts[3198:218564] critical:   at MapCallouts.Application.Main (string[]) [0x00008] in /Users/Adam/Downloads/Callout/Main.cs:16
2015-11-02 13:12:06.304 MapCallouts[3198:218564] critical:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00060, 0xffffffff>
2015-11-02 13:12:06.304 MapCallouts[3198:218564] critical: 
Native stacktrace:

2015-11-02 13:12:06.304 MapCallouts[3198:218564] critical: 
=================================================================
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.
=================================================================

## Notes

=== Xamarin Studio ===

Version 5.9.8 (build 0)
Installation UUID: 11a26d86-0d21-407a-8da9-8c197ecc0ad1
Runtime:
	Mono 4.0.5 ((detached/1d8d582)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400050001

=== Apple Developer Tools ===

Xcode 7.1 (9079)
Build 7B91b

=== Xamarin.iOS ===

Version: 9.1.0.27 (Business Edition)
Hash: 1f068b4
Branch: master
Build date: 2015-10-27 18:59:21-0400

=== Xamarin.Android ===

Version: 5.1.9.0 (Business Edition)
Android SDK: /Users/Adam/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
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: 2.0.2.111 (Business Edition)

=== Build Information ===

Release ID: 509080000
Git revision: cc5f6e5658589ca7f46210c57fad947e75f30abd
Build date: 2015-10-21 19:27:41-04
Xamarin addins: d77f191bd7d3451adf837b85b38f2b7c60004400

=== Operating System ===

Mac OS X 10.11.1
Darwin Adams-Retina-MacBook-Pro.local 15.0.0 Darwin Kernel Version 15.0.0
    Sat Sep 19 15:53:46 PDT 2015
    root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-12-03 17:20:57 UTC
The problem is that SFAnnotation.Coordinate and BridgeAnnotation.Coordinate returns a different result every time they're called (because the coordinates are randomized).

If instead a randomized coordinate is created in the constructor, and that is returned from the Coordinate getter, everything works just fine:

	CLLocationCoordinate2D coordinate;

	public SFAnnotation ()
	{
		coordinate.Latitude = 37.786996 + BridgeAnnotation.r.NextDouble() / 100;
		coordinate.Longitude = -122.419281 + BridgeAnnotation.r.NextDouble() / 100;
	}

	public override CoreLocation.CLLocationCoordinate2D Coordinate {
		get	{
			return coordinate;
		}
	}