I have a simple class which does reverse geocoding, but it causes the app to crash (SIGSEGV
), sometimes (50%) but not consistently.
I have tried running it in the UI thread, and in background threads and at different parts of the ViewController's life cycle, but it seems random. Not much is happening in the app when it starts up, mostly just building the UI via MonoTouch.Dialog
MKReverseGeocoder coder;
MyMKReverseGeocoderDelegate myMKReverseGeocoderDelegate;
public void RequestReverseGeocode (CLLocationCoordinate2D coordinate, Action<MKPlacemark> callback)
{
myMKReverseGeocoderDelegate= new MyMKReverseGeocoderDelegate (callback);
coder = new MKReverseGeocoder (coordinate);
coder.Delegate = myMKReverseGeocoderDelegate;
coder.Start ();
}
internal class MyCLRequestLocationManagerDelegate : CLLocationManagerDelegate
{
Action<CLLocation> callback;
public MyCLRequestLocationManagerDelegate (Action<CLLocation> callback)
{
this.callback = callback;
}
public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
manager.StopUpdatingLocation ();
locationManager = null;
callback (newLocation);
}
public override void Failed (CLLocationManager manager, NSError error)
{
callback (null);
}
}
The crash details are here:
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 MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:34
at AlternativeFuelingStationLocator.Application.Main (string[]) [0x00000] in
/Users/vink/Dropbox/Dev/iOS/UNIVERSAL/DOE/AlternativeFuelingStationLocator/AlternativeFuelingStationLocator/Main.cs:16
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
(object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Native stacktrace:
0 AlternativeFuelingStationLocator 0x000e1018
mono_handle_native_sigsegv + 408
1 AlternativeFuelingStationLocator 0x00011d9f
mono_sigsegv_signal_handler + 351
2 libsystem_c.dylib 0x9ad7759b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 MapKit 0x01e3b4cf MKMapRectRemainder +
101422
5 GeoServices 0x0617f3b8 GEOTileKeyContainsKey +
166198
6 GMM 0x092a3f3d
GEOTileKeyFromGMMTilePath + 31777
7 ProtocolBuffer 0x061dfcf1 ProtocolBuffer + 19697
8 Foundation 0x0192aa59
___NSURLConnectionDidFinishLoading_block_invoke_0 + 40
9 Foundation 0x01928e94
__65-[NSURLConnectionInternal
_withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 40
10 Foundation 0x01929eb7
-[NSURLConnectionInternalConnection invokeForDelegate:] + 39
11 Foundation 0x01928e4f
-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 201
12 Foundation 0x01928fd5
-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 76
13 Foundation 0x0186df6a
_NSURLConnectionDidFinishLoading + 43
14 CFNetwork 0x00c68bbd
_ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE
+ 241
15 CFNetwork 0x00d355ea
_ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl
+ 584
16 CFNetwork 0x00c5f298
_ZN19URLConnectionClient13processEventsEv + 174
17 CFNetwork 0x00d3516b
_ZThn52_N25URLConnectionInstanceData24multiplexerClientPerformEv + 21
18 CFNetwork 0x00c5f137
_ZN17MultiplexerSource7performEv + 259
19 CoreFoundation 0x012ab97f
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x0120eb73 __CFRunLoopDoSources0 +
243
21 CoreFoundation 0x0120e454 __CFRunLoopRun + 1012
22 CoreFoundation 0x0120ddb4 CFRunLoopRunSpecific +
212
23 CoreFoundation 0x0120dccb CFRunLoopRunInMode + 123
24 GraphicsServices 0x0489f879 GSEventRunModal + 207
25 GraphicsServices 0x0489f93e GSEventRun + 114
26 UIKit 0x022a6a9b UIApplicationMain + 1175
27 ??? 0x0e0b6fcd 0x0 + 235630541
28 ??? 0x0e0b6c18 0x0 + 235629592
29 ??? 0x0e0b6184 0x0 + 235626884
30 ??? 0x0e0b5fdc 0x0 + 235626460
31 ??? 0x0e0b612e 0x0 + 235626798
32 AlternativeFuelingStationLocator 0x00011aef mono_jit_runtime_invoke
+ 1407
33 AlternativeFuelingStationLocator 0x0022011a mono_runtime_invoke +
170
34 AlternativeFuelingStationLocator 0x00222e51 mono_runtime_exec_main +
705
35 AlternativeFuelingStationLocator 0x00222061 mono_runtime_run_main +
929
36 AlternativeFuelingStationLocator 0x000ad6df mono_jit_exec + 239
37 AlternativeFuelingStationLocator 0x002f41ca main + 5194
38 AlternativeFuelingStationLocator 0x00003345 start + 53
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.
It looks like a GC issue (garbage collection).
When I took all the involved objects and made them class variables the problem went away.