2

I'm having trouble with my iOS app. Here is my ticket against the component in question: https://github.com/lxcid/LXReorderableCollectionViewFlowLayout/issues/52

But for StackOverflow - my question is more general. How does one go about debugging something like this?

The only error I get is:

2013-12-16 18:23:24.307 3rdRevolution[33315:70b] *** -[CFSet countByEnumeratingWithState:objects:count:]: message sent to deallocated instance 0x1336f850
(lldb) 

Here is a screenshot of xcode:

cl.ly/SzXL

I did find that LXReordableCollectionView is involved in the crash by commenting out its usage which solved the crash. But I still don't know why or how to solve it. And commenting out code to figure things out doesn't seem like a great approach..

Suggestions?

Thanks!

Rob
  • 415,655
  • 72
  • 787
  • 1,044
phil swenson
  • 8,564
  • 20
  • 74
  • 99
  • 1
    A case of a dangling pointer. The instance formerly allocated at 0x1336f850 has been released, hence is not available anymore. Enable zombies. See http://stackoverflow.com/questions/5386160/how-to-enable-nszombie-in-xcode for more. – Till Dec 17 '13 at 01:33
  • 1
    @Till I think the presence of this error message means that he already turned on zombies. – Rob Dec 17 '13 at 03:04
  • correct, zombies are on. – phil swenson Dec 17 '13 at 03:45
  • Add an exception breakpoint will help you out where you are getting exception or which variable is getting released. – Leena Dec 17 '13 at 06:00
  • 1
    @philswenson Is this ARC code? If not, the static analyzer ("Analyze" on Xcode's "Product" menu) can be invaluable in finding issues in non-ARC code. – Rob Dec 17 '13 at 08:05

2 Answers2

6
  1. If it's your own custom class, put an NSLog in the dealloc. If not, subclass the class you're using, override dealloc with [super dealloc] and an NSLog.
  2. Figure out when the object is being deallocated exactly.
  3. Figure out why it's being deallocated then.
nhgrif
  • 61,578
  • 25
  • 134
  • 173
0

I enabled Zombies in the Scheme Diagnostics and found out which class was causing the error (it was a view controller).

It was releasing an already deallocated instance of the class, which is a weird thing to see in an ARC project so it had me stumped.

Turned out I had overlooked a warning. I had a method that should have returned a value but wasn't.

Once I corrected that error the crash stopped.

BlackPocket
  • 1
  • 1
  • 1