0

I am having a error that is tough to find/fix. The error is *** -[NSConcreteData release]: message sent to deallocated instance 0xdee4440

I followed this post to enable zombies within my application: How do I set up NSZombieEnabled in Xcode 4?

I have the "All Exceptions" breakpoint set. As well as the "malloc_error_break" and "-[_NSZombie methodSignatureForSelector:]" symbolic breakpoints.

my stack trace looks like:

0 ___forwarding___
1 _CF_forwarding_prep_0
2 objc_release

Is there anyway to generate a better stack trace? or stop on the line of code that is the culprit?

Community
  • 1
  • 1
Mausimo
  • 8,018
  • 12
  • 52
  • 70
  • Do you explicitly release a NSData variable anywhere? – Jeremy Mar 20 '13 at 17:53
  • I do. This has been driving me crazy, so I went and commented out the release code for those NSData. However, I am still getting the error. I also have NSData objects returned from methods that are autoreleased. Could the auto-released NSData be the culprit? – Mausimo Mar 20 '13 at 17:57
  • It's likely...but only if a release message is sent to one of them. For example: `NSData *someAutoreleaseData = [self fetchAutoreleasedData]; [someAutoreleaseData release];` would be an issue assuming your function did, in fact, return an autoreleased instance. – Jeremy Mar 20 '13 at 17:57
  • When a function returns an auto-released object, do you have to retain the object right away? I have been doing: `NSData *someAutoreleaseData = [[self fetchAutoreleasedData] retain]; [someAutoreleaseData release];` – Mausimo Mar 20 '13 at 18:07
  • Not unless you need access to that information outside of the scope relative to that variable assignment. But even so, your example wouldn't cause the error. It's only if you release without retaining/init/copy/new that would cause an issue. – Jeremy Mar 20 '13 at 18:10
  • I figured out my problem, after searching high and low. In my object, I have 2 NSData retained properties. In my dealloc method I had written [instance-variable dealloc] instead of [instance-variable release]. Well, that was a fun 3 hours.... sigh. – Mausimo Mar 20 '13 at 18:13
  • Good job! The joys of programming. – Jeremy Mar 20 '13 at 18:15
  • @Jeremy one more question. If I have: `NSData *someAutoreleaseData = [self fetchAutoreleasedData]; [self someMethodTakingData:someAutoreleaseData];` Will the NSData passed into someMethodTakingData be released at anytime, perhaps before the end of the someMethodTakingData function? – Mausimo Mar 20 '13 at 18:17
  • In that case, the `someAutoreleaseData` variable will be scheduled for release at the end of the method from which it was assigned. Since it was assigned outside of `someMethodTakingData`, it will continue to live when `someMethodTakingData` has completed. – Jeremy Mar 20 '13 at 18:23

1 Answers1

0

I figured out my problem, after searching high and low.

In my object, I have 2 NSData retained properties. In my dealloc method I had written [instance-variable dealloc] instead of [instance-variable release].

Mausimo
  • 8,018
  • 12
  • 52
  • 70