View Full Version : double free error while loading main Nib
Mar 31, 2008, 03:32 PM
Hey there again MR programmers. I've got a real perplexing one this time.
I turned off the Objective-C v2.0 garbage collection for a bit to test my memory management code for leaks and such...and got a bit more than I bargained for. I'm running into a malloc double free error, and while I know what causes this from my searching I can't possibly imagine why it would be happening in my case. The error seems to be triggered upon a call to dyld_stub_NSPopAutoreleasePool, which in turn looks to be part of a loadNib call. I'm not doing anything weird with Nibs, just loading a main one through Info.plist.
Any ideas? Let me know if you need more background, or I can post the project if needed.
Mar 31, 2008, 05:26 PM
Just to clarify what I'm talking about with NSPopAutoreleasePool and loadNib, here's two screen shots. The After shot is a single step after the Before, so it's happening right there.
EDIT: Looking at it again, it looks like the errors aren't showing "double free" anymore...huh. I wonder what it is that I've changed in the last couple hours that did that. Time to hit the Dropbox revisions.
Mar 31, 2008, 06:54 PM
Somewhat related question as I try to debug this...
Does anyone have an idea why I'd get "Function "-[_NSZombie init]" not defined." from GDB if I try "fb -[_NSZombie init]" with NSZombieEnabled on? Also, GDB is the *****.
EDIT: Well here's some more interesting stuff, though it doesn't get me any closer to figuring out what's wrong.
2008-03-31 18:56:15.469 Converter[2955:813] *** -[CFArray release]: message sent to deallocated instance 0x158660
(gdb) shell malloc_history 2955 0x158660
Call  [arg=32]: thread_a0919fa0 |start | main | NSApplicationMain | +[NSBundle(NSNibLoading) loadNibNamed:owner:] | +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] | +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] | loadNib | -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] | -[NSIBObjectData instantiateObject:] | -[NSCustomObject nibInstantiate] | -[Controller init] | -[Controller initializeTypeArray] | -[Controller addConvertType:withUnitSet1:withUnitSet2:] | -[Type init] | +[NSArray arrayWithObjects:] | -[__NSPlaceholderArray initWithObjects:count:] | CFArrayCreate | __CFArrayInit | _CFRuntimeCreateInstance | malloc_zone_malloc
That just tells me somethings going wrong when the Nib is loading, but can anyone decipher what exactly is going wrong?
EDIT2: Haha, well I guess I didn't need the help after all. Ignore the thread noise.
If any was curious, I was doing exactly what I expected I was (releasing an autoreleased object, from a convenience constructor)...I just couldn't find it. malloc_history is gonna be one of my new favorite toys, I can tell.