Track down an autorelease bug

Posts: 306
Joined: 2009.03
Post: #1
I have been trying to use zombies to help me catch an exception that is comming from the autorelease code. I cannot tell what happened since its not from my thread but I had read a lot of places describing how to setup zombies(brains) to help you figure these out. I have tried the following things:
Arguments tab-Added
NSDebugEnabled "YES"
MallocStackLoggingNoComp "YES"
MallocStackLogging "YES"
NSZombieEnabled "YES"
CFZombies 5

in my main somewhere somebody said to do:
NSZombieEnabled = YES;

seems redundant but what the heck I did that too.
I have the following breakpoints:
-[_NSZombie methodSignatureForeSelector:]
-[_NSZombie release]

along with a bunch of other debug breakpoints

I hit an autorelease pool exception and the only thing I see in the console is:
***I think the stuff above this is just from startup***
Program received signal: “EXC_BAD_ACCESS”.
warning: Unable to restore previously selected frame.

Unable to disassemble .objc_class_name_NSKeyValueUndefinedSetter.

No details as to what was being released twice etc. Does anyone know how you make this sucker work? I also read that it doesnt work for a lot of toll free\CF classes such as NSString etc. Is this likely the problem or am I doing something wrong? Finally the stack trace output is binary data. Does some program view this data ?


Eeep. Update I tried forcing this bug with one of my own objects and it works, so I guess that means this is one of those toll free things? I saw this on the console
2009-06-27 14:58:05.651 SubHunt[12604:20b] *** -[SoundManager release]: message sent to deallocated instance 0x109c750

Does anyone have any suggestions to debug this if I cannot use zombies?
Quote this message in a reply
Posts: 306
Joined: 2009.03
Post: #2
After hours and hours of debugging, I narrowed it down to 1 line:
FloatingText* levelNameText=[[FloatingText alloc] initWithText:[NSString stringWithFormat:@"Stage %d %@",[level levelNumber],levelName] at:CGPoint_create(25,250) textDescriptor:desc duration:300];
//[worldTexts addObject:levelNameText];
[levelNameText release];

I cannot understand why adding something to an array would cause an autorelease issue. With that line commented out it works fine. If anyone has any ideas I would love to hear it.
Quote this message in a reply
Posts: 306
Joined: 2009.03
Post: #3
Solved with help of random bug somebody saw in my code. I had a string copy and a malloc to make room for the copy. The malloc was using length and not length+1 which would allow for the null char. So the strcopy was writing to memory outside it bounds and who knows what it was doing. Fixing that did it.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Is implementing autorelease code in constructor a good idea ? Bracer 4 4,805 Oct 13, 2009 12:41 PM
Last Post: SethWillits
  OpenGL|ES tutorials - Follows NeHe track. dragagon 39 47,818 May 19, 2009 11:10 AM
Last Post: sthaqu
  Autorelease pools Gillissie 16 10,516 Apr 22, 2009 02:43 PM
Last Post: kalimba