Bug 4636 - Multiple MKAnnotations -> Detail click = crash - Intermittent
Summary: Multiple MKAnnotations -> Detail click = crash - Intermittent
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-04-25 04:30 UTC by uwantfries
Modified: 2012-04-25 06:43 UTC (History)
2 users (show)

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


Attachments
Handle_Annotation_Click with mutliple Annotations (7.51 MB, application/zip)
2012-04-25 04:30 UTC, uwantfries
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 INVALID

Description uwantfries 2012-04-25 04:30:16 UTC
Created attachment 1743 [details]
Handle_Annotation_Click with mutliple Annotations

If I add a single MKAnnotation (as per http://docs.xamarin.com/ios/recipes/Content_Controls/Map_View/Handle_Annotation_Click) it works OK.

Adding more than one (see attachment lines 37+38) causes the app to crash intermittently.

Error:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2012-04-25 09:15:33.262 MapView[555:1407] -[__NSCFString BridgeSelector]: unrecognized selector sent to instance 0x9b2a1a0
Stacktrace:

  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
  at MapView.Application.Main (string[]) [0x00000] in /Users/solvdltd/Downloads/Handle_Annotation_Click/Main.cs:15
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   MapView                             0x0009094c mono_handle_native_sigsegv + 284
	1   MapView                             0x000d5e5d sigabrt_signal_handler + 109
	2   libSystem.B.dylib                   0x99da905b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   libSystem.B.dylib                   0x99e365a5 raise + 26
	5   libSystem.B.dylib                   0x99e4c6e4 abort + 93
	6   libSystem.B.dylib                   0x99dc8b1b _Unwind_Resume + 59
	7   CoreFoundation                      0x010f7e39 CFRunLoopRunSpecific + 345
	8   CoreFoundation                      0x010f7ccb CFRunLoopRunInMode + 123
	9   GraphicsServices                    0x04789879 GSEventRunModal + 207
	10  GraphicsServices                    0x0478993e GSEventRun + 114
	11  UIKit                               0x02190a9b UIApplicationMain + 1175
	12  ???                                 0x09ff77ac 0x0 + 167737260
	13  ???                                 0x09ff6958 0x0 + 167733592
	14  ???                                 0x09ff67f0 0x0 + 167733232
	15  ???                                 0x09ff687f 0x0 + 167733375
	16  MapView                             0x0000a042 mono_jit_runtime_invoke + 722
	17  MapView                             0x00169f4e mono_runtime_invoke + 126
	18  MapView                             0x0016e034 mono_runtime_exec_main + 420
	19  MapView                             0x00173455 mono_runtime_run_main + 725
	20  MapView                             0x00067245 mono_jit_exec + 149
	21  MapView                             0x002116a5 main + 2837
	22  MapView                             0x00003095 start + 53

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================


Version Info:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MonoDevelop 2.8.8.4

Runtime:
	Mono 2.10.9 (tarball Tue Apr 17 18:59:12 EDT 2012)
	GTK 2.24.10
	GTK# (2.12.0.0)
Mono for Android: 4.0.6.52253989 (Evaluation)
Apple Developer Tools:
	 Xcode 4.2 (828)
	 Build 4C199
Monotouch: 5.2.11
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-04-25 06:43:11 UTC
The problem is that MapDelegate.GetViewForAnnotation is called once for each annotation. You store the detailButton at class-level, but only the last one created. This means that the previous ones will be freed by the GC, and then the app crashes when you click on one of the freed buttons.

You must store all the detailButtons you create on class-level, not only the last one.