Skip navigation.
 
mlAutoreleasepool problems
FROM : Kay Roepke
DATE : Wed Jul 19 19:54:05 2006

Hi *!

I'm totally stumped here. I have a parser framework and simple shell 
tool which uses the framework to parse some sample input text for 
testing.
What happens is this:
In main() I create an autorelease pool and call my parser. After 
lexing & parsing the input correctly, I release the pool as the last 
thing in main().
The release fails (this is with NSDebugEnabled=YES, 
NSAutoreleaseFreedObjectCheckEnabled=YES):
LL-star[4339] *** _NSAutoreleaseFreedObject(): release of previously 
deallocated object (0x30c7d0) ignored

At this point there should only by NSCF* objects in the pool. But in 
addition there are two entries of my own object there, which I 
positively have notautoreleased myself. I do not call autorelease 
anywhere in my code.
These two entries are the same object, which lives in a static 
variable (think singleton) representing an EOF token. I am using 
NSObjects (its superclass) to alloc/init the instance. Making it non-
static (recreating it and risking a leak for debugging this problem) 
doesn't make a difference, nor should it.

Re-reading TN2124 and NSDebug.h hasn't given me a solution to the 
problem. In addition, when I look at the output of [NSAutoreleasePool 
showPools] prior to the alloc call to the EOFToken class it shows the 
same number of autoreleased objects (in this case 81) as right before 
the crash, but there are two NSCFString entries in the pool at the 
very same address as my EOFTokens later occupy. WTF?
Here is some of the output:

2006-07-19 19:24:13.853 LL-star[4339] before eofToken alloc
2006-07-19 19:24:13.853 LL-star[4339] (null)                <-- this is the 
eofToken local variable prior to alloc (==nil)
LL-star[4339] Pool (level = 0): 81 objects ====================
LL-star[4339]     0x30c7d0 (NSCFString)
LL-star[4339]     0x30c7d0 (NSCFString)
LL-star[4339]     0x30b670 (NSCFNumber)
LL-star[4339]     0x30c660 (NSCFNumber)
...
later on it looks like this

2006-07-19 19:24:13.855 LL-star[4339] after eofToken alloc
#0  0x929205e4 in __NSAutoreleaseObject ()
#1  0x929204c0 in -[NSObject autorelease] ()
#2  0x929355fc in _NSDescriptionWithLocaleFunc ()
#3  0x907c1ad0 in _CFStringAppendFormatAndArgumentsAux ()
#4  0x907c0988 in _CFStringCreateWithFormatAndArgumentsAux ()
#5  0x9294f314 in NSLogv ()
#6  0x9294f2b0 in NSLog ()
#7  0x000179dc in +[ANTLRToken eofToken] (self=0x20708, _cmd=0x1e024) 
at /Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/
ANTLRToken.m:22
#8  0x0001c6d0 in -[ANTLRCommonTokenStream LT:] (self=0x3089b0, 
_cmd=0x1e4b4, k=1) at /Users/kroepke/Projects/antlr3/code/antlr/main/
lib/ObjC/ANTLRCommonTokenStream.m:214
#9  0x0001ca1c in -[ANTLRCommonTokenStream LA:] (self=0x3089b0, 
_cmd=0x1d6fc, k=1) at /Users/kroepke/Projects/antlr3/code/antlr/main/
lib/ObjC/ANTLRCommonTokenStream.m:256
#10 0x000048ec in -[SimpleC program] (self=0x309e70, _cmd=0xb684) at /
Users/kroepke/Projects/antlr3/code/antlr/main/lib/ObjC/examples/LL-
star/SimpleC.m:286
#11 0x00002acc in main () at /Users/kroepke/Projects/antlr3/code/
antlr/main/lib/ObjC/examples/LL-star/main.m:22
2006-07-19 19:24:14.101 LL-star[4339] <ANTLRToken: 0x30c7d0>
LL-star[4339] Pool (level = 0): 81 objects ====================
LL-star[4339]     0x30c7d0 (ANTLRToken)
LL-star[4339]     0x30c7d0 (ANTLRToken)
LL-star[4339]     0x30b670 (NSCFNumber)
LL-star[4339]     0x30c660 (NSCFNumber)
...

I have set breakpoints on +[NSAutoreleasePool addObject:], -
[NSAutoreleasePool addObject:], __NSAutoreleaseObject(), and have 
overriden retain, release, autorelease for my EOFToken class (which 
simply log and call through to super) to pinpoint the problem. 
googling turned up a lot of irrelevant crap (as it goes...:( )

What makes me particularly nervous are the first two entries in the 
pool, plus that I do not see any autorelease activity on the EOFToken 
instance anywhere, not in the source, not in the debugger.
Please note that I was forced to build my own gdb-477 version with 
the dreaded assertion in my_value_equal() in varobj.c:2007 commented 
out, so I could use the debugger at all.

Any takers?


Thanks,

-k
--
Kay Röpke <<email_removed>>
classdump Software

Related mailsAuthorDate
mlAutoreleasepool problems Kay Roepke Jul 19, 19:54
mlRe: Autoreleasepool problems Shawn Erickson Jul 19, 20:11
mlRe: Autoreleasepool problems Kay Roepke Jul 19, 20:28
mlRe: Re: Autoreleasepool problems Shawn Erickson Jul 19, 20:41
mlRe: Autoreleasepool problems Kay Roepke Jul 19, 21:16
mlRe: Autoreleasepool problems Jerry Krinock Jul 19, 21:39
mlRe: Autoreleasepool problems Kay Roepke Jul 19, 22:02
mlNew debugging feature request? Was: Autoreleasepool problems Scott Ribe Jul 20, 18:34