sigsegv crash on iphone from crittercism - iphone

I've got a couple sigsegv crashes coming in from crittercism, but I'm not quite sure how to start going about debugging. The only line of code that's mine is the main call from the start of the crashed thread.
Copying the crashed thread's stack trace from crittercism:
Reason:
24-Sep-12
02:38:14 PM SIGSEGV
main (main.m:11)
Stack:
0
0 libobjc.A.dylib 0x356265b0 objc_msgSend + 15
1
1 UIKit 0x3861c313 + 1310
2
2 UIKit 0x386337cf + 206
3
3 UIKit 0x385ef80b + 258
4
4 QuartzCore 0x34f56d63 + 214
5
5 QuartzCore 0x34f56901 + 460
6
6 QuartzCore 0x34f57835 + 16
7
7 QuartzCore 0x34f5721b + 238
8
8 QuartzCore 0x34f57029 + 316
9
9 UIKit 0x386786e5 + 572
10
10 UIKit 0x386784a3 + 66
11
11 UIKit 0x38677391 + 1464
12
12 UIKit 0x385ed1ef + 2458
13
13 UIKit 0x385ec6d5 + 72
14
14 UIKit 0x385ec123 + 6154
15
15 GraphicsServices 0x3779f5a3 + 590
16
16 CoreFoundation 0x372f0683 + 14
17
17 CoreFoundation 0x372efee9 + 212
18
18 CoreFoundation 0x372eecb7 + 646
19
19 CoreFoundation 0x37261ebd CFRunLoopRunSpecific + 356
20
20 CoreFoundation 0x37261d49 CFRunLoopRunInMode + 104
21
21 GraphicsServices 0x3779e2eb GSEventRunModal + 74
22
22 UIKit 0x38640301 UIApplicationMain + 1120
23
23 MyApp 0x35bf main (main.m:11)

First, you'll need to "symbolicate" the crash log. There are plenty of web pages out there to instruct you on that.
Since this stack ends at objc_msgSend, the most likely cause is a dangling pointer.
To debug those, I recommend using NSZombies. If you are testing on the simulator, you might try "Guard malloc".

This crash is caused by invoking a method on a pointer to an object that was already deallocated. It is a very common ref count error somewhere in your code that holds on the UIKit elements. But, what you should do at a matter of practice is upload your .DSYM file to the crittercism. It can be done manually via the website or via a Web API call as part of your automatic build process.

Related

Crash with MapKit on iOS 6

I have not been able to reproduce this particular crash myself but it has been reported via our crash reporting tool and is being experienced by several hundred of our users. Finding it hard to debug or reproduce.
It happens on all hardware platforms but only on iOS 6. Any help or insights will be highly appreciated.
Exception Type:SIGSEGVCode:SEGV_ACCERR
Fatal Exception
Thread 0 Crashed
0 MapKit _remove(objc_object*, MKQuadTrieNode*) + 13
1 MapKit -[MKQuadTrie remove:] + 54
2 MapKit -[MKAnnotationContainerView observeValueForKeyPath:ofObject:change:context:] + 252
3 Foundation NSKeyValueNotifyObserver + 272
4 Foundation NSKeyValueWillChange + 572
5 Foundation -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:] + 180
6 Foundation NSKVOForwardInvocation + 130
7 CoreFoundation ___forwarding___ + 626
8 CoreFoundation _CF_forwarding_prep_0 + 24
9 MapKit -[MKUserLocation _updateCoordinate] + 106
10 MapKit -[MKUserLocation setLocation:] + 106
11 MapKit -[MKMapView(UserPositioningInternal) locationManagerUpdatedLocation:] + 994
12 CoreFoundation -[NSArray makeObjectsPerformSelector:withObject:] + 206
13 MapKit -[MKLocationManager _reportLocationStatus:] + 66
14 MapKit -[MKLocationManager locationProvider:didUpdateLocation:] + 1540
15 MapKit -[MKCoreLocationProvider locationManager:didUpdateLocations:] + 864
16 CoreLocation -[CLLocationManager onClientEventLocation:] + 1614
17 CoreLocation __CLClientInvokeCallback_block_invoke_0 + 64
18 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
19 CoreFoundation __CFRunLoopDoBlocks + 160
20 CoreFoundation __CFRunLoopRun + 1450
21 CoreFoundation CFRunLoopRunSpecific + 356
22 CoreFoundation CFRunLoopRunInMode + 104
23 GraphicsServices GSEventRunModal + 74
24 UIKit UIApplicationMain + 1120
25 App Name main.m line 14 main + 14
Try setting the delegate method of the locationManager to nil in the dealloc method of the class you are using it in
Something like this:
-(void) dealloc
{
self.locationManager.delegate = nil;
}
What might be happening is that the object is being deallocated (maybe due to low memory) and the location manager is trying to send a message to a non existing delegate.

using testFlight i got my application crash log but don't know what went wrong

I have one application and in beta testing i got my application crash but i am not able to understand what is wrong with it, can you suggest me where to look, Thanks :)
0 TurfNutritionTool_ver_5.1 0x00189642 testflight_backtrace + 142
1 TurfNutritionTool_ver_5.1 0x0018a1d0 TFSignalHandler + 212
2 libsystem_c.dylib 0x3174872e _sigtramp + 42
3 UIKit 0x362f2aa0 -[UITableView dealloc] + 56
4 CoreFoundation 0x317b5c42 -[NSObject(NSObject) release] + 30
5 libobjc.A.dylib 0x3125d50c objc_setProperty_non_gc + 120
6 libobjc.A.dylib 0x31255046 objc_setProperty + 26
7 TurfNutritionTool_ver_5.1 0x001051c8 -[TNTScenarioViewController setScenarioTable:] (TNTScenarioViewController.m:15)
8 TurfNutritionTool_ver_5.1 0x00103610 -[TNTScenarioViewController viewDidUnload] (TNTScenarioViewController.m:160)
9 UIKit 0x362a9a28 -[UIViewController unloadViewForced:] + 172
10 UIKit 0x362b96b8 -[UIViewController unloadViewIfReloadable] + 16
11 UIKit 0x3630012c -[UIViewController purgeMemoryForReason:] + 40
12 UIKit 0x3630014c -[UIViewController didReceiveMemoryWarning] + 16
13 TurfNutritionTool_ver_5.1 0x00102682 -[TNTScenarioViewController didReceiveMemoryWarning] (TNTScenarioViewController.m:40)
14 UIKit 0x36300162 -[UIViewController _didReceiveMemoryWarning:] + 14
15 Foundation 0x3113f182 _nsnote_callback + 142
16 CoreFoundation 0x3182020e __CFXNotificationPost_old + 402
17 CoreFoundation 0x317baeea _CFXNotificationPostNotification + 118
18 Foundation 0x3113c5d2 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
19 Foundation 0x3113e1c0 -[NSNotificationCenter postNotificationName:object:] + 24
20 UIKit 0x362d6360 -[UIApplication _performMemoryWarning] + 48
21 UIKit 0x362d6d82 -[UIApplication _receivedMemoryNotification] + 126
22 UIKit 0x362d4506 _memoryStatusChanged + 42
23 CoreFoundation 0x31820d68 __CFNotificationCenterDarwinCallBack + 24
24 CoreFoundation 0x3181dbde __CFMachPortPerform + 210
25 CoreFoundation 0x31828a96 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
26 CoreFoundation 0x3182a83e __CFRunLoopDoSource1 + 166
27 CoreFoundation 0x3182b60c __CFRunLoopRun + 520
28 CoreFoundation 0x317bbec2 CFRunLoopRunSpecific + 230
29 CoreFoundation 0x317bbdca CFRunLoopRunInMode + 58
30 GraphicsServices 0x336d641e GSEventRunModal + 114
31 GraphicsServices 0x336d64ca GSEventRun + 62
32 UIKit 0x361abd68 -[UIApplication _run] + 404
33 UIKit 0x361a9806 UIApplicationMain + 670
34 TurfNutritionTool_ver_5.1 0x000edb68 main (main.m:14)
35 TurfNutritionTool_ver_5.1 0x000edb27 start + 39
Are you familiar with the concept of a stack trace? What you are looking at are the lines of code execution from the crash (0) back to a recent frame entry. As such, this is referred to as a 'back trace' since it goes backwards from the point that the code stopped executing.
I have no knowledge of your code, but you can see from line 14 of the back trace that you received a low memory warning. This warning caused a chain of unload events, including a deallocation of a UITableView (line 3).
This is immediately followed by the _sigtramp, which probably indicates an EXC_BAD_ACCESS. My guess, without seeing the rest of your code, is that you are accessing something that has been released by the low memory unload situation.

App crashes but only when it's build for Ad-Hoc distro

My problem is this. I have an app that builds and runs fine in Debug mode, no crashes, memory errors, etc. As soon as I do an Ad-hoc build and try to run it on the device the main thread crashes at a certain point, for no apparent reason... The stack trace I managed to get from the device log is thus...
0 libSystem.B.dylib 0x30d7c2d4 __kill + 8
1 libSystem.B.dylib 0x30d7c2c4 kill + 4
2 libSystem.B.dylib 0x30d7c2b6 raise + 10
3 libSystem.B.dylib 0x30d90d72 abort + 50
4 libstdc++.6.dylib 0x34981a20 __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x34a83594 _objc_terminate + 104
6 libstdc++.6.dylib 0x3497fdf2 __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x3497fe46 std::terminate() + 10
8 libstdc++.6.dylib 0x3497ff16 __cxa_throw + 78
9 libobjc.A.dylib 0x34a824c4 objc_exception_throw + 64
10 CoreFoundation 0x3587a7c2 +[NSException raise:format:arguments:] + 62
11 CoreFoundation 0x3587a7fc +[NSException raise:format:] + 28
12 QuartzCore 0x31071222 CALayerSetPosition(CALayer*, CA::Vec2<double> const&, bool) + 134
13 QuartzCore 0x31071190 -[CALayer setPosition:] + 32
14 UIKit 0x341e4378 -[UIView(Geometry) setCenter:] + 16
15 MyApp 0x00012b2c 0x1000 + 72492
16 MyApp 0x0001276a 0x1000 + 71530
17 UIKit 0x341e3270 -[UIViewController view] + 104
18 UIKit 0x341efd04 -[UIViewController contentScrollView] + 16
19 UIKit 0x341efb74 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 24
20 UIKit 0x341efa72 -[UINavigationController _layoutViewController:] + 18
21 UIKit 0x341ef4cc -[UINavigationController _startTransition:fromViewController:toViewController:] + 248
22 UIKit 0x341ef358 -[UINavigationController _startDeferredTransitionIfNeeded] + 176
23 UIKit 0x341e30be -[UINavigationController pushViewController:transition:forceImmediate:] + 634
24 UIKit 0x341e2e34 -[UINavigationController pushViewController:animated:] + 28
25 MyApp 0x00004f80 0x1000 + 16256
26 UIKit 0x3420b834 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 656
27 UIKit 0x342cb60c -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 124
28 Foundation 0x31181df6 __NSFireDelayedPerform + 362
29 CoreFoundation 0x3583109c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
30 CoreFoundation 0x35830b54 __CFRunLoopDoTimer + 844
31 CoreFoundation 0x358021ae __CFRunLoopRun + 1082
32 CoreFoundation 0x35801c80 CFRunLoopRunSpecific + 224
33 CoreFoundation 0x35801b88 CFRunLoopRunInMode + 52
34 GraphicsServices 0x320c84a4 GSEventRunModal + 108
35 GraphicsServices 0x320c8550 GSEventRun + 56
36 UIKit 0x341dc322 -[UIApplication _run] + 406
37 UIKit 0x341d9e8c UIApplicationMain + 664
The other really strange thing is that if you close the app and stop it running (after the crash) in the background and then relaunch it, it bails out almost immediately quoting...
<Warning>: Application 'MyApp' exited abnormally with signal 11: Segmentation fault
Which I'm lead to believe is a memory access error (uninitialised memory access). I'm not doing anything crazy with pointers or anything so all I can presume is that it's a problem with the CF libraries...
Any thoughts or help would be HUGELY appreciated :)
It's hard to say exactly what the answer is without knowing more, but my first guess is that you are providing some invalid value to a UIView's center property.
There are two pieces of information missing that could help you/me find the answer.
First, lines like these in the stack trace need to be symbolicated:
15 MyApp 0x00012b2c 0x1000 + 72492
16 MyApp 0x0001276a 0x1000 + 71530
Knowing what is happening in those two lines will help you track it down, and knowing what the exception that got thrown (starting at line 11 in the stack trace) contains will help further. You may be able to get this information from looking at the device's Console output in Xcode's Organizer.
You can symbolicate the crash report if you have the dSYM file that was created when you built the app for AdHoc distribution. Dragging the crash report into Xcode's Organizer window will attempt to symbolicate it automatically. If that doesn't work, you can try using the symbolicatecrash script directly. It's tucked away in a path like this:
/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash

App Crashing in NSURLConnection

I am trying to figure out what is causing this crash. I have built and given the app to our testers but we cannot seem to reproduce this reliably. It just happens sometimes...
Thread 0 Crashed:
0 libobjc.A.dylib 0x000027da objc_msgSend + 18
1 Foundation 0x00032896 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 62
2 Foundation 0x00032818 _NSURLConnectionDidFinishLoading + 72
3 CFNetwork 0x00010dd8 URLConnectionClient::_clientDidFinishLoading(URLConnectionClient::ClientConnectionEventQueue*) + 160
4 CFNetwork 0x00004ad4 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 96
5 CFNetwork 0x000049c4 URLConnectionClient::processEvents() + 64
6 CFNetwork 0x00004976 URLConnection::multiplexerClientPerform(RunLoopMultiplexer*) + 30
7 CFNetwork 0x000048f4 MultiplexerSource::perform() + 120
8 CFNetwork 0x00004872 MultiplexerSource::_perform(void*) + 2
9 CoreFoundation 0x00055f1e __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
10 CoreFoundation 0x00027ba0 __CFRunLoopDoSources0 + 376
11 CoreFoundation 0x00027444 __CFRunLoopRun + 224
12 CoreFoundation 0x00027270 CFRunLoopRunSpecific + 224
13 CoreFoundation 0x00027178 CFRunLoopRunInMode + 52
14 GraphicsServices 0x000045ec GSEventRunModal + 108
15 GraphicsServices 0x00004698 GSEventRun + 56
16 UIKit 0x0000411c -[UIApplication _run] + 396
17 UIKit 0x00002128 UIApplicationMain + 664
18 myapp 0x000020d8 main (main.m:14)
19 myapp 0x0000208c start + 32
Any advice would be greatly appreciated. The app is built in XCode 3.2.4 using SDK 4.1.
Cheers...
I would try turning on NSZombieEnabled and see if that sheds any light on the issue. Is the delegate for the connection still around and valid?
Ben has some sound advice. Turn NSZombieEnabled to on.
I can tell you with almost 100% certainty that it is crashing because you have a nil object when the delegate is attempting to send it a message.
The fact that it is only crashing sometimes, tells me that you are probably using autorelease. Autorelease never decrements the retain count at exactly the same time, so sometimes your object will still be alive when it gets a delegate message and the app works. However, sometimes that object will have been released and the app crashes.

Getting strange intermittent "unrecognized selector" exceptions in iPhone app

Recently, I've been getting intermittent error reports from my app claiming "unrecognized selector" in areas that could not possibly cause them, and yet they do.
For example, this one:
Error: NSInvalidArgumentException: *** -[NSCFString didReceiveMemoryWarning]: unrecognized selector sent to instance 0x541fe0
0 CoreFoundation 0x32de1e23 __handleUncaughtException + 230
1 libobjc.A.dylib 0x3266d894 _objc_terminate + 156
2 libstdc++.6.dylib 0x338c3a8c _ZN10__cxxabiv111__terminateEPFvvE + 84
3 libstdc++.6.dylib 0x338c3b04 _ZSt9terminatev + 24
4 libstdc++.6.dylib 0x338c3c2c __cxa_throw + 108
5 libobjc.A.dylib 0x3266be5c objc_exception_throw + 112
6 CoreFoundation 0x32de2bfd -[NSObject doesNotRecognizeSelector:] + 112
7 CoreFoundation 0x32d67b19 ___forwarding___ + 480
8 CoreFoundation 0x32d5e840 _CF_forwarding_prep_0 + 48
9 Foundation 0x33f765d9 _nsnote_callback + 184
10 CoreFoundation 0x32d9e511 _CFXNotificationPostNotification + 304
11 Foundation 0x33f741b3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
12 Foundation 0x33f76519 -[NSNotificationCenter postNotificationName:object:] + 20
13 UIKit 0x30d18db8 -[UIApplication _performMemoryWarning] + 68
14 UIKit 0x30d18d50 -[UIApplication _receivedMemoryNotification] + 136
15 UIKit 0x30d18c80 _memoryStatusChanged + 64
16 CoreFoundation 0x32d66eb7 __CFNotificationCenterDarwinCallBack + 26
17 CoreFoundation 0x32d5cb51 __CFMachPortPerform + 78
18 CoreFoundation 0x32da452b CFRunLoopRunSpecific + 2302
19 CoreFoundation 0x32da3c1f CFRunLoopRunInMode + 50
20 GraphicsServices 0x31bb9374 GSEventRunModal + 196
21 UIKit 0x30bf3c30 -[UIApplication _run] + 560
22 UIKit 0x30bf2230 UIApplicationMain + 968
23 Mind 0x00002c68 main + 72
24 Mind 0x00002be4 start + 52
This is the OS sending a memory warning to my app, and somehow the application class has changed into a string.
It seems to happen a lot more when the code is invoked via an NSOperation:
Error: NSInvalidArgumentException: -[NSCFString setObject:forKey:]: unrecognized selector sent to instance 0x3e793088
9 Mind 0x0015de70 -[CCTextureCache textureFromFile:] + 528
10 Mind 0x0015d9f4 -[CCTextureCache loadImageUncached:pixelFormat:] + 116
11 Mind 0x0015d058 -[CCTextureCache addImage:pixelFormat:] + 152
12 Mind 0x00080524 -[ImageLoader imageWithFile:pixelFormat:] + 84
13 Mind 0x000854c4 -[ImageLoadOperation performLoad] + 68
14 Mind 0x00085800 -[ResourceLoadOperation main] + 112
15 Foundation 0x30c4c8b5 -[__NSOperationInternal start] + 664
16 Foundation 0x30c4c613 -[NSOperation start] + 22
17 Foundation 0x30cbdb63 ____startOperations_block_invoke_2 + 46
18 libSystem.B.dylib 0x31227858 _dispatch_call_block_and_release + 20
19 libSystem.B.dylib 0x3122863c _dispatch_worker_thread2 + 128
20 libSystem.B.dylib 0x311b1544 _pthread_wqthread + 400
21 libSystem.B.dylib 0x311a8b74 __stack_chk_fail + 4294967295
The code in question is:
[textures setObject:texture forKey:filename];
textures is type NSMutableDictionary* and never gets reassigned or deallocated (naturally, since this is a cache object). This is the only place where setObject is invoked in this method, yet according to the stack trace, textures was a string.
I also get this weirdness:
Error: NSInvalidArgumentException: -[NSConcreteNotification getPixelFormatForIdentifier:]: unrecognized selector sent to instance 0x5c021b0
9 Mind 0x0015dd0c -[CCTextureCache textureFromFile:] + 172
10 Mind 0x0015d9f4 -[CCTextureCache loadImageUncached:pixelFormat:] + 116
11 Mind 0x0015d058 -[CCTextureCache addImage:pixelFormat:] + 152
12 Mind 0x00080524 -[ImageLoader imageWithFile:pixelFormat:] + 84
13 Mind 0x000854c4 -[ImageLoadOperation performLoad] + 68
14 Mind 0x00085800 -[ResourceLoadOperation main] + 112
15 Foundation 0x347b78b5 -[__NSOperationInternal start] + 664
16 Foundation 0x347b7613 -[NSOperation start] + 22
17 Foundation 0x34828b63 ____startOperations_block_invoke_2 + 46
18 libSystem.B.dylib 0x32a2f858 _dispatch_call_block_and_release + 20
19 libSystem.B.dylib 0x32a3063c _dispatch_worker_thread2 + 128
20 libSystem.B.dylib 0x329b9544 _pthread_wqthread + 400
21 libSystem.B.dylib 0x329b0b74 __stack_chk_fail + 4294967295
This trace is from the following code in CCTextureCache:
CCTexture2DPixelFormat pixelFormat = [self getPixelFormatForIdentifier:identifier];
How CCTextureCache changed into NSConcreteNotification after having already called a number of methods on itself is baffling to say the least.
Has anyone else noticed this sort of thing? Am I somehow getting memory corruption?
Did you check some race conditions about multi-threads ? It seems like some resource freed by another thread, and current thread send a messaged to a deallocated object.
Error: NSInvalidArgumentException: -[NSCFString setObject:forKey:]: unrecognized selector sent to instance 0x3e793088
9 Mind 0x0015de70 -[CCTextureCache textureFromFile:] + 528
10 Mind 0x0015d9f4 -[CCTextureCache loadImageUncached:pixelFormat:] + 116
11 Mind 0x0015d058 -[CCTextureCache addImage:pixelFormat:] + 152
12 Mind 0x00080524 -[ImageLoader imageWithFile:pixelFormat:] + 84
13 Mind 0x000854c4 -[ImageLoadOperation performLoad] + 68
14 Mind 0x00085800 -[ResourceLoadOperation main] + 112
15 Foundation 0x30c4c8b5 -[__NSOperationInternal start] + 664
16 Foundation 0x30c4c613 -[NSOperation start] + 22
17 Foundation 0x30cbdb63 ____startOperations_block_invoke_2 + 46
18 libSystem.B.dylib 0x31227858 _dispatch_call_block_and_release + 20
19 libSystem.B.dylib 0x3122863c _dispatch_worker_thread2 + 128
20 libSystem.B.dylib 0x311b1544 _pthread_wqthread + 400
21 libSystem.B.dylib 0x311a8b74 __stack_chk_fail + 4294967295
This is often caused by memory management errors. Did you try zombies?
...with zombies enabled, messages to deallocated objects will no longer behave
strangely or crash in difficult-to-understand ways, but will instead log a message
and die in a predictable and debugger-breakpointable way. This is the tool to use
when trying to track down over-releases and premature releases.
I just ran into the same problem, but it turns out I had made a stupid mistake:
I had declared a member like this in the header file:
NSMutableDictionary* myDict;
But then initialized it like this in the .m file:
myDict = [[NSDictionary alloc] init];
which is valid and all, because the NSMutableDictionary is derived from the NSDictionary class. Therefore all calls that are inherited from NSDictionary actually worked, but the calls specific to NSMutableDictionary [setObject: forKey:] failed because I tried to invoke them on the parent class.
The mistake was really dumb, but I was also thrown off by the fact that the debugger reported the type of myDict as something totally different (neither NSDictionary, nor NSMutableDictionary). I hope this helps some other tired coder :-)