I am trying to reproduce such crash(es):
There's Manual Reference Counting in my project. Also, there's a lot of multi-threading.
Some of the properties are not thread-safe. :(
I have just one assumption about the cause of this crash: some object is overreleased (?).
I've added automated UI tests (Appium
), but they haven't helped yet.
Also, I've profiled for Zombies
- everything seems ok.
Also, I've tried Xcode's Static Analyzer ( Product -> Analyze
), there're a lot of warnings, but none of them seems to be a cause of such crash (I've looked at the warning Incorrect decrement of reference count not owned at this point
).
I created a test project with MRC, and added such code:
- (void)testAssumptions {
//@autoreleasepool
{
[self overReleaseNilValue];
[self overReleaseNotNilValue];
}
}
- (void)overReleaseNilValue {
NSIndexPath* path = [[NSIndexPath alloc] initWithIndex:42];
[path release];
[path release];
}
- (void)overReleaseNotNilValue {
NSIndexPath* path = nil;
[path release];
[path release];
}
Releasing an object twice doesn't crash neither with autorelease pool enabled nor without a pool.
So my questions are:
1. What can be another reason of such crash except of releasing already released object?
2. Are there ways to increase a probability of reproducing such crash? E.g. some env. variable which reduces some autorelease pool tolerance to unsafe code? Or some additional autorelease pool?
3. Why doesn't my test project code crash?
Any comments are highly appreciated.