Program error when switching between tabs 5 times

I have a strange error. I'm not sure how to track her down. I am running my application in Simmulator 3.0. It has three tabs on the tabBarcontroller, lets you call them tab1, tab2 and tab3. All three tabs are a subclass of a custom grouped table. If I press between tabs 1 and 3 indefinitely, there is no problem. However, if I press from tab1 or tab3 to tab2 exactly five times, the program crashes after pressing tab1 or tab3. I had two different backtracks (mostly identical) when I do this:

backtrace1:

objc[2988]: FREED(id): message release sent to freed object=0xfec100
Program received signal:  "EXC_BAD_INSTRUCTION".
(gdb) backtrace
#0  0x92a2dbfa in _objc_error ()
#1  0x92a2dc30 in __objc_error ()
#2  0x92a2c637 in _freedHandler ()
#3  0x302042e8 in CFRelease ()
#4  0x00370c31 in CALayerUpdateSublayers ()
#5  0x0036f173 in -[CALayer dealloc] ()
#6  0x0036100e in CALayerRelease ()
#7  0x00369dad in CALayerFreeTransaction ()
#8  0x003620b8 in CA::Transaction::commit ()
#9  0x0036a2e0 in CA::Transaction::observer_callback ()
#10 0x30245c32 in __CFRunLoopDoObservers ()
#11 0x3024503f in CFRunLoopRunSpecific ()
#12 0x30244628 in CFRunLoopRunInMode ()
#13 0x32044c31 in GSEventRunModal ()
#14 0x32044cf6 in GSEventRun ()
#15 0x309021ee in UIApplicationMain ()
#16 0x0000208a in main (argc=1, argv=0xbfffefbc) at /Users/johnbulcher/Documents/myApps/AnApp/main.m:14

      

backtrace2:

Program received signal:  "EXC_BAD_ACCESS".
(gdb) backtrace
#0  0x92a3d688 in objc_msgSend ()
#1  0x302042e8 in CFRelease ()
#2  0x00370c31 in CALayerUpdateSublayers ()
#3  0x0036f173 in -[CALayer dealloc] ()
#4  0x0036100e in CALayerRelease ()
#5  0x00369dad in CALayerFreeTransaction ()
#6  0x003620b8 in CA::Transaction::commit ()
#7  0x0036a2e0 in CA::Transaction::observer_callback ()
#8  0x30245c32 in __CFRunLoopDoObservers ()
#9  0x3024503f in CFRunLoopRunSpecific ()
#10 0x30244628 in CFRunLoopRunInMode ()
#11 0x32044c31 in GSEventRunModal ()
#12 0x32044cf6 in GSEventRun ()
#13 0x309021ee in UIApplicationMain ()
#14 0x0000208a in main (argc=1, argv=0xbfffefbc) at /Users/johnbulcher/Documents/myApps/AnApp/main.m:14

      

I have not managed to duplicate backtrace1 yet, although backtrace2 is as consistent as the hour one. There are two strange things about this disaster:

1) Programmatically switching between tabs using "tabBarController.selectedIndex" does not crash the application - I need to manually select the tabs to collapse the application. 2) I don't see any of my code listed in the back line other than the main one. The line of code pointed backwards is

 int retVal = UIApplicationMain(argc, argv, nil, @"AnAppDelegate");

      

Where should I start looking for this error?

+2


source to share


2 answers


Based on the stack trace, it will appear that the OS is finished moving from one view to another and is trying to clean up something that has already been deallocated. My guess is that you have both the application and the OS, but you have freed your side more than you kept it, causing the subsequent OS version to crash. The first backtrace is a double free release of an object that has already been released; the second tries to send a message to an object that no longer exists.



+1


source


(couldn't comment, so I had to use the answer slot)

I have a similar problem, also using custom table cells. My cells are created based on the tutorial found here (12:02 minutes ahead are most relevant):

 MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (cell == nil) {
  [[NSBundle mainBundle] loadNibNamed:@"MyTableCellView" owner:self options:nil];
  cell = self.myTableCell;
 }

      

I have one MyTableCellView.xib

that has its owner pointed to TableViewController

. The controller has an myTableCell

IB output .

I have no problems / leaks. Clang / LLVM does not cause problems. I am doing a stress test with "Simulate Memory Warning" in the simulator. The app crashes every time with an error similar to yours.



EDIT

Finally figured it out!

Well, I didn't know what you should be using IBOutlet

in didReceiveMemoryWarning

(similarly viewDidUnload

).

It would be nice if it reappears before flipback, so there is no "flickr" when returning to main screen after memory notification.

0


source







All Articles