My app works great when I build and debug but when I run on its own, it crashes due to some other issues.
I have one NSObject class, one UITableView class, one UIView class , one UITableViewCell class and one NSOperation class.
Does any body have similar issues or if any one can help me out.
Application Specific Information:
objc_msgSend() selector name: release
iPhone Simulator 235, iPhone OS 4.2 (iPhone/8C134)
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x01134a67 objc_msgSend + 27
1 UIKit 0x004ab1e2 -[UITableViewCell removeFromSuperview] + 167
2 UIKit 0x003249d9 -[UIView dealloc] + 340
3 UIKit 0x0032e281 -[UIScrollView dealloc] + 341
4 UIKit 0x003661ce -[UITableView dealloc] + 1085
5 Foundation 0x000698da __delayedPerformCleanup + 59
6 CoreFoundation 0x00f4bbde CFRunLoopTimerInvalidate + 446
7 CoreFoundation 0x00fb57d7 __CFRunLoopDoTimer + 1799
8 CoreFoundation 0x00f11cc9 __CFRunLoopRun + 1817
9 CoreFoundation 0x00f11240 CFRunLoopRunSpecific + 208
10 CoreFoundation 0x00f11161 CFRunLoopRunInMode + 97
11 GraphicsServices 0x01874268 GSEventRunModal + 217
12 GraphicsServices 0x0187432d GSEventRun + 115
13 UIKit 0x002fa42e UIApplicationMain + 1160
14 Time 0x00001e08 main + 102 (main.m:14)
15 Time 0x00001d99 start + 53
This technote has the technical info on crashlogs:
http://developer.apple.com/library/mac/#technotes/tn2004/tn2123.html
However, you are having a debugging problem, not a crashlog problem.
See tips for debugging here:
http://www.cocoadev.com/index.pl?DebuggingTechniques
Interpreting crash logs takes practice. People here see this: removeFromSuperview and immediately think "Aha, a clue! this is likely a memory issue" because removeFromSuperview will remove a view then decrement it's retain count. if the retain count is already zero, then decrementing one more time may lead to a crash. Thus, they think you are over releasing your UITableViewCell
check your UITableViewCell for alloc/init, release or autorelease...
Related
My app (named MyLittleApplication) crashes randomly when I click on a button that pops view controller.
I could use some help (to find out where should I start looking) with crash log:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x600332e0
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x351faf78 objc_msgSend + 16
1 Foundation 0x37d0a74c NSKVOPendingNotificationCreate + 216
2 Foundation 0x37d0a652 NSKeyValuePushPendingNotificationPerThread + 62
3 Foundation 0x37cfc744 NSKeyValueWillChange + 408
4 Foundation 0x37cd3848-[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:] + 176
5 Foundation 0x37d55a14 _NSSetPointValueAndNotify + 76
6 UIKit 0x311f825a -[UIScrollView(Static) _adjustContentOffsetIfNecessary] + 1890
7 UIKit 0x31215a54 -[UIScrollView setFrame:] + 548
8 UIKit 0x31215802 -[UITableView setFrame:] + 182
9 POViO 0x000fcac8 0xf8000 + 19144
10 UIKit 0x31211b8e -[UIViewController _setViewAppearState:isAnimating:] + 138
11 UIKit 0x3126b8a8 -[UIViewController beginAppearanceTransition:animated:] + 184
12 UIKit 0x3121490c -[UINavigationController _startTransition:fromViewController:toViewController:] + 832
13 UIKit 0x312144fc -[UINavigationController _startDeferredTransitionIfNeeded] + 244
14 UIKit 0x3125e8e4 _popViewControllerNormal + 184
15 UIKit 0x3125e712 -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:] + 386
16 UIKit 0x31242bba -[UINavigationController popToViewController:transition:] + 626
17 POViO 0x001074e6 0xf8000 + 62694
18 CoreFoundation 0x374553f6 -[NSObject performSelector:withObject:withObject:] + 46
19 UIKit 0x311eae00 -[UIApplication sendAction:to:from:forEvent:] + 56
20 UIKit 0x311eadbc -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 24
21 UIKit 0x311ead9a -[UIControl sendAction:to:forEvent:] + 38
22 UIKit 0x311eab0a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 486
23 UIKit 0x311eb442 -[UIControl touchesEnded:withEvent:] + 470
24 UIKit 0x311e9924 -[UIWindow _sendTouchesForEvent:] + 312
25 UIKit 0x311e9312 -[UIWindow sendEvent:] + 374
26 UIKit 0x311cf68e -[UIApplication sendEvent:] + 350
27 UIKit 0x311cef34 _UIApplicationHandleEvent + 5820
28 GraphicsServices 0x33c11224 PurpleEventCallback + 876
29 CoreFoundation 0x374cf51c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
30 CoreFoundation 0x374cf4be __CFRunLoopDoSource1 + 134
31 CoreFoundation 0x374ce30c __CFRunLoopRun + 1364
32 CoreFoundation 0x3745149e CFRunLoopRunSpecific + 294
33 CoreFoundation 0x37451366 CFRunLoopRunInMode + 98
34 GraphicsServices 0x33c10432 GSEventRunModal + 130
35 UIKit 0x311fdcce UIApplicationMain + 1074
36 MyLittleApplication 0x000f90ae 0xf8000 + 4270
37 MyLittleApplication 0x000f9048 0xf8000 + 4168
I suspect that it has something to do with notificationCenter and UIDeviceOrientationDidChangeNotifications I use. Is this true or am I looking in the wrong direction?
I am calling
[notificationCenter removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]
in viewDidUnload, this shuld be enough?
Can you please tell me what bug should i start looking for?
This is a stacktrace you see the stack of methods called when the crash happened.
You start at the bottom and work yourself up to the top and search for a method call from your app (the stacktrace includes calls from the frameworks too (e.g. -[UIScrollView(Static) _adjustContentOffsetIfNecessary])).
The topmost method call from your app is likely the cause of your error and you can see what the system tried afterwards.
In your case it seems that you call popToViewController and the iOS frameworks try to animate the transition from one UIViewController to the next. There seems to be a problem for the table view to set its frame and scroll to the contentOffset.
This is likely to be caused by a memory error. You get this hint by examining Exception Type: EXC_BAD_ACCESS (SIGSEGV)
EXC_BAD_ACCESS is likely a hint that you try to acces a something which is no more in the memory -> already released.
In general I would recomment to activate exveption breakpoints in Xcode:
Have you set the exception breakpoint?
got to breakpoint editor pane
click on the x in the bottom left corner
choose add exception breakpoint
Now you should see a stacktrace if an exception occurs. And Xcode should be at the line where the crash happens.
The second thing you should get familiar with is the zombie mode in Instruments.
You can find a good introduction to the zombi mode in this video.
In your case, you can see you have a EXC_BAD_ACCESS (SIGSEGV). This means you're trying to access something which isn't here, or at least was here but isn't anymore. If you can replicate the error, try using the Zombies mode of Instruments, it will tell will which thing it was expecting to access. The solution to this problem is often that you released the resource too early a resource you still need.
You might want to throw some NSLog statements in the methods just so you can have an idea of where things are going wrong. Sometimes those iOS messages can be a little cryptic.
I am using AdWhirl in my iphone app and I am displaying the adView in several different views. Each view has a different adView ivar. Problem is that when I am switching the views quickly, ASIHttpRequest within Adwhirl code tries to call the view after the view has been deallocted. I have tried setting the delegate to nil in my view but to no avail. Are there any other workarounds to cancel the AdWhirl ASIHttpRequest when the view is deallocated. In my view dealloc I am doing something like:
adView.delegate = nil;
adView = nil
where adView is an ivar declared like:
#property (nonatomic, retain) AdWhirlView *adView;
Crash Log:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000c
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x32ad5c98 objc_msgSend + 16
1 SocialMashup 0x0005503c -[ASIHTTPRequest requestReceivedResponseHeaders:] (ASIHTTPRequest.m:1954)
2 CoreFoundation 0x36387efc -[NSObject(NSObject) performSelector:withObject:] + 16
3 Foundation 0x32cfe7a2 __NSThreadPerformPerform + 262
4 CoreFoundation 0x363f1a72 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
5 CoreFoundation 0x363f3758 __CFRunLoopDoSources0 + 376
6 CoreFoundation 0x363f44e4 __CFRunLoopRun + 224
7 CoreFoundation 0x36384ebc CFRunLoopRunSpecific + 224
8 CoreFoundation 0x36384dc4 CFRunLoopRunInMode + 52
9 GraphicsServices 0x30cdd418 GSEventRunModal + 108
10 GraphicsServices 0x30cdd4c4 GSEventRun + 56
11 UIKit 0x3037cd62 -[UIApplication _run] + 398
12 UIKit 0x3037a800 UIApplicationMain + 664
13 ZFirewall.dylib 0x013dcb24 0x13cd000 + 64292
14 SocialMashup 0x000024ae main (main.m:17)
15 SocialMashup 0x00002444 start + 32
I'm pretty sure AdWhirl doesn't use ASIHTTPRequest at all. Maybe a particular ad network you're using does, but the logs don't even seem to point to AdWhirl as the culprit.
I have problems analyzing my crashlog. The iPhone crashes sometimes, when I click on the app icon to start the app. The app is already "running" in background, but it's not active. This is the symbolized crash log:
Thread 0 Crashed:
0 libobjc.A.dylib 0x33479470 objc_msgSend + 28
1 CoreLocation 0x3436f68e -[CLLocationManager onClientEvent:supportInfo:] + 98
2 CoreLocation 0x3436f804 OnClientEvent + 16
3 CoreLocation 0x3436b522 CLClientInvokeCallback(__CLClient*, CLClientEvent, __CFDictionary const*) + 42
4 CoreLocation 0x3436cf74 CLClientHandleDaemonDataRegistration(__CLClient*, CLDaemonCommToClientRegistration const*, __CFDictionary const*) + 668
5 CoreLocation 0x3436d4c8 CLClientHandleDaemonData(__CFMessagePort*, long, __CFData const*, void*) + 212
6 CoreFoundation 0x33a813fe __CFMessagePortPerform + 242
7 CoreFoundation 0x33a556f8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
8 CoreFoundation 0x33a556bc __CFRunLoopDoSource1 + 160
9 CoreFoundation 0x33a47f76 __CFRunLoopRun + 514
10 CoreFoundation 0x33a47c80 CFRunLoopRunSpecific + 224
11 CoreFoundation 0x33a47b88 CFRunLoopRunInMode + 52
12 GraphicsServices 0x33b0e4a4 GSEventRunModal + 108
13 GraphicsServices 0x33b0e550 GSEventRun + 56
14 UIKit 0x32099322 -[UIApplication _run] + 406
15 UIKit 0x32096e8c UIApplicationMain + 664
16 Norddeich 0x00002764 main (main.m:14)
17 Norddeich 0x00002718 start + 32
As far as i understand the stack trace, the error occurred in the main.m. Line 14 is part of the default code:
int retVal = UIApplicationMain(argc, argv, nil, nil);
Please give me a hint, how to find the error.
Thank you in advance!
Do you set it's delegate to nil before returning from controller (or at least in controller's dealloc)? I suspect CLLocationManager is trying to send a message to delegate which is deallocated already - that's why it crashes at obj_msgSend.
I had this same problem testing my app on 4.3, but not in 5.0. The issue was that I was trying to dealloc the CLLocationManager inside one of the delegate methods. It works fine in 5.0, but crashes a iPhone 3GS running 4.3 every time.
In the end I made the CLLocationManager object a property, then in the delegate method set the delegate to nil and dispatched a block to the main thread to release the object.
My autorelease pool is crashing my app at random, what is the common cause of this problem?
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x0145ba63 objc_msgSend + 23
1 CoreFoundation 0x01210a6c CFRelease + 92
2 CoreFoundation 0x012f2e8a -[__NSArrayM dealloc] + 170
3 CoreFoundation 0x01210a6c CFRelease + 92
4 CoreFoundation 0x01235b8d _CFAutoreleasePoolPop + 237
5 Foundation 0x0005886c __NSFireDelayedPerform + 559
6 CoreFoundation 0x012dafe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
7 CoreFoundation 0x012dc594 __CFRunLoopDoTimer + 1220
8 CoreFoundation 0x01238cc9 __CFRunLoopRun + 1817
9 CoreFoundation 0x01238240 CFRunLoopRunSpecific + 208
10 CoreFoundation 0x01238161 CFRunLoopRunInMode + 97
11 GraphicsServices 0x01c2e268 GSEventRunModal + 217
12 GraphicsServices 0x01c2e32d GSEventRun + 115
13 UIKit 0x002e842e UIApplicationMain + 1160
14 FancyAPint 0x000029e8 main + 102 (main.m:14)
15 FancyAPint 0x00002979 start + 53
I know this is because an object is being over released, am i correct in thinking an object is being released before the autorelease pool is trying to release it. Therefore the autorelease pool attempts to over release an object?
Your assessment is correct. Try running your app using the "Zombies" instrument in the simulator, or setting the NSZombieEnabled environmental variable to YES. These will both give you more information about what objects are being overreleased.
This will be because of extra memory releases. Do not release the object which is being allocated inside auto-release pool and is inited from object which has its own memory. This may the one reason behind this as i also faced this problem.
My app crashes when I do [self.navigationController popViewControllerAnimated:YES].
It crashes more on Device than on Simulator. Please suggest how to fix this?
Date/Time: 2010-11-09 10:51:41.325 +0800
OS Version: iPhone OS 4.0.1 (8A306)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000286e objc_msgSend + 18
1 CoreFoundation 0x00002c30 -[NSObject(NSObject) release] + 24
2 libobjc.A.dylib 0x00003c1a objc_setProperty + 114
3 UIKit 0x000693d4 -[UINavigationController setDisappearingViewController:] + 24
4 UIKit 0x0007d5c0 -[UINavigationController _clearLastOperation] + 40
5 UIKit 0x0007d4b4 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 556
6 UIKit 0x0007d248 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 204
7 UIKit 0x0007d0b6 -[UINavigationTransitionView _navigationTransitionDidStop] + 450
8 UIKit 0x00059974 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
9 UIKit 0x0005987e -[UIViewAnimationState animationDidStop:finished:] + 34
10 QuartzCore 0x000127ba run_animation_callbacks(double, void*) + 286
11 QuartzCore 0x0001265c CA::timer_callback(__CFRunLoopTimer*, void*) + 116
12 CoreFoundation 0x00071a54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
13 CoreFoundation 0x00073ede __CFRunLoopDoTimer + 854
14 CoreFoundation 0x0007485e __CFRunLoopRun + 1082
15 CoreFoundation 0x0001d8e4 CFRunLoopRunSpecific + 224
16 CoreFoundation 0x0001d7ec CFRunLoopRunInMode + 52
17 GraphicsServices 0x000036e8 GSEventRunModal + 108
18 GraphicsServices 0x00003794 GSEventRun + 56
19 UIKit 0x000062a0 -[UIApplication _run] + 396
20 UIKit 0x00004e10 UIApplicationMain + 664
21 tenpay 0x00006124 main (main.m:13)
22 tenpay 0x00002324 start + 44
myviewcontroller = [[[MyViewController alloc]init]autorelease];
[self.navigationController pushViewController:myviewcontroller animated:YES];
[myviewcontroller release]; //This is my bug !!! I just fixed it.
This usually means you are sending a message to a released object which is a bad idea.
From the stack you can see that it is sending a release message to an object. I'd suggest that the object has already been released and thus hasa retain count of 0. Therefore a further release would be invalid.
I believe if you turn on a flag, I think it's called Zombie detection or something like that, then any message to a released object will generate a more descriptive message.
Perhaps a more experienced developer can jump in here with more details.
Yes, I believe Derek is pointing you in the right direction. Could you possibly list what kind of memory-related operations you are performing on the active controller before sending this release message (the release message is being sent implicitly when you try to pop it out). Please clarify if you are using autorelease for this controller,etc... Also it might be helpful to see what are the associated properties that you may have associated with this controller (ex: #property(nonatomic, retain, etc...)) if there are any.