popViewControllerAnimated:YES crashes my app

0

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
iphone
uinavigationcontroller
crash
asked on Stack Overflow Nov 9, 2010 by Daolong Wang

3 Answers

2
myviewcontroller = [[[MyViewController alloc]init]autorelease];
[self.navigationController pushViewController:myviewcontroller animated:YES];
[myviewcontroller release]; //This is my bug !!!  I just fixed it.
answered on Stack Overflow Dec 30, 2011 by user678724
1

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.

answered on Stack Overflow Nov 9, 2010 by drekka
1

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.

answered on Stack Overflow Nov 9, 2010 by Zaki Saadeh

User contributions licensed under CC BY-SA 3.0