Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#11 Error in L4LoggerStore updateChildren:withParent:

open
nobody
None
5
2010-05-17
2010-05-17
Gideon
No

I am getting an error "-[CFArray count]: message sent to deallocated instance" in updateChildren:withParent:, and although I haven't looked deeply into the code, it appears that a hierarchy is maintained for classes and subclasses, and this scenario may happen if a subclass has logged something and then the superclass logs something, so the logger factory needs to create a logger for the class, and set the already existing children to point to the newly created superclass logger.

When I look at the code, L4LoggerStore:305 calls [node count], and tracing that back, at line 143, theNode (called node in line 305) is retrieved from the repository under the key aName, then in line 166, that place in the repository dictionary is replaced by theLogger, so by this stage, theNode will be released, and then the call where the crash comes is in line 167, after the object has been removed from the dictionary, and therefore released.

Seeing as the repository is not referenced in updateChildren:withParent:, I would suggest swapping lines 166 and 167, so that that block is now:

theLogger = [aFactory newLoggerInstance:aName];
[theLogger setLoggerRepository:self];
[self updateChildren:theNode withParent:theLogger ];
[repository setObject:theLogger forKey:aName];
[self updateParentsOfLogger:theLogger];
[loggers addObject:theLogger];

Hope this helps.

Discussion