Question

Is there some method to know crash reason in Xcode 4.6?

The crash stack is :
Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0xd9f2c061
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                     0x3a74f5aa objc_msgSend + 10
1   Foundation                          0x33157599 -[NSNotificationCenter postNotificationName:object:userInfo:] + 73
2   UIKit                               0x347830cd -[UIApplication _handleApplicationSuspend:eventInfo:] + 733
3   UIKit                               0x346f91e7 -[UIApplication handleEvent:withNewEvent:] + 2459
4   UIKit                               0x346f86cd -[UIApplication sendEvent:] + 73
5   UIKit                               0x346f811b _UIApplicationHandleEvent + 6155
6   GraphicsServices                    0x363ee5a3 _PurpleEventCallback + 591
Was it helpful?

Solution

When you add an observer to the notification centre you have to remove it when the object is being dealloced/destroyed. Otherwise Notification Centre would send the notification to the destroyed object resulting in crash.

1 - check if you properly handle the removing from notification centre. (typically you do this on dealloc method)

2 - If step 1 doesn't help, profile your application with instruments & zombies. it would point out which object is destroyed but still receiving messages.

OTHER TIPS

Almost certainly an object registered with the notification centre to receive that notification and then failed to deregister before deallocation.

The easiest way to catch the problem would be to enable NSZombies — see e.g. this tutorial. If you run with zombies enabled then objects that should have been deallocated remain in memory but raise an exception if anyone attempts to call them. So you can figure out exactly what type of object the notification centre is attempting to call and therefore which object is probably making the mistake.

Given the name of the origin of the notification — _handleApplicationSuspend:eventInfo: — you might also want to have a quick check of anyone registering for UIApplicationWillResignActiveNotification, UIApplicationDidEnterBackgroundNotification and the others related to application suspension.

Might be an useful information that it appears to crash only on ios7, as my project ran perfectly on ios6.

Maybe userInfo is has nil value....

[[NSNotificationCenter defaultCenter] postNotificationName:SayLoggedInNotification object:wSelf userInfo:@{@"from": wSelf.from}];
# wSelf.form is nil
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top