Reputation: 1826
I have a bug where I'm crashing in the Autorelease function. Classic: Access object after over-release.
The problem is that the iOS program is using EAAccessory and happening somewhere as a result of data being received from the device.
As a result, the problem needs to be diagnosed off the Simulator. Due to the memory requirements of NSZombie, NSZombie is disabled for iOS outside the simulator.
Any tips/ideas how to track down an over-release bug that would be easy with NSZombie in the iOS world outside the simulator?
I've already contemplated trying to stub the behaviour of the EAAcessory for the simulator; but due to time constraints that more of a "Next rev-refactor/enhancement" due to the amount of work needed.
Right now I just need to find the bad access bug.
Upvotes: 1
Views: 407
Reputation: 63707
Since I don't have experience with EAAccessory I don't know if this is viable, but here is a suggestion. From retain/release debugging (rentzsch.tumblr.com):
#if 1
- (id)retain {
NSUInteger oldRetainCount = [super retainCount];
id result = [super retain];
NSUInteger newRetainCount = [super retainCount];
printf("%s<%p> ++retainCount: %lu => %lu\n", [[self className] UTF8String], self, oldRetainCount, newRetainCount);
printf("%s\n", [[[NSThread callStackSymbols] description] UTF8String]);
return result;
}
- (void)release {
NSUInteger oldRetainCount = [super retainCount];
BOOL gonnaDealloc = oldRetainCount == 1;
if (gonnaDealloc) {
printf("%s<%p> --retainCount: 1 => 0 (gonna dealloc)\n", [[self className] UTF8String], self);
printf("%s\n", [[[NSThread callStackSymbols] description] UTF8String]);
}
[super release];
if (!gonnaDealloc) {
NSUInteger newRetainCount = [super retainCount];
printf("%s<%p> --retainCount: %lu => %lu\n", [[self className] UTF8String], self, oldRetainCount, newRetainCount);
printf("%s\n", [[[NSThread callStackSymbols] description] UTF8String]);
}
}
#endif
You can add a filter by class to run the debug code only for specific classes you suspect.
Upvotes: 1