I am using testflight to test my app, and I have a crash that only occurs when the app is built for ad-hoc and distributed through test flight. The relevant crash report details are:
Date/Time: 2012-06-11 09:00:34.638 +0800
OS Version: iPhone OS 5.1.1 (9B206)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000009
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x34e74f78 objc_msgSend + 16
1 appName 0x0002963e __24-[XYPieChart reloadData]_block_invoke_0168 (XYPieChart.m:321)
2 libdispatch.dylib 0x30295c52 _dispatch_call_block_and_release + 6
3 libdispatch.dylib 0x302a0e8a _dispatch_main_queue_callback_4CF$VARIANT$up + 190
4 CoreFoundation 0x371482a6 __CFRunLoopRun + 1262
5 CoreFoundation 0x370cb49e CFRunLoopRunSpecific + 294
6 CoreFoundation 0x370cb366 CFRunLoopRunInMode + 98
7 GraphicsServices 0x3388a432 GSEventRunModal + 130
8 UIKit 0x30e77cce UIApplicationMain + 1074
9 appName 0x00003b20 main (main.m:14)
10 appName 0x00003ad8 0x1000 + 10968
and the code that is referenced - (XYPieChart.m:321)
[CATransaction begin];
[CATransaction setAnimationDuration:_animationSpeed];
[_pieView setUserInteractionEnabled:NO];
__block NSMutableArray *layersToRemove = nil;
[CATransaction setCompletionBlock:^{
if (layersToRemove) {
[layersToRemove enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if (obj)
[obj removeFromSuperlayer];
}];
[layersToRemove removeAllObjects];
}
for(SliceLayer *layer in _pieView.layer.sublayers)
{
[layer setZPosition:kDefaultSliceZOrder];
}
[_pieView setUserInteractionEnabled:YES];
}];
BOOL isOnStart = ([slicelayers count] == 0 && sliceCount);
NSInteger diff = sliceCount - [slicelayers count];
layersToRemove = [NSMutableArray arrayWithArray:slicelayers];
BOOL isOnEnd = ([slicelayers count] && (sliceCount == 0 || sum <= 0));
if(isOnEnd)
{
for(SliceLayer *layer in _pieView.layer.sublayers){
[self updateLabelForLayer:layer value:0];
[layer createArcAnimationForKey:@"startAngle"
fromValue:[NSNumber numberWithDouble:_startPieAngle]
toValue:[NSNumber numberWithDouble:_startPieAngle]
Delegate:self];
[layer createArcAnimationForKey:@"endAngle"
fromValue:[NSNumber numberWithDouble:_startPieAngle]
toValue:[NSNumber numberWithDouble:_startPieAngle]
Delegate:self];
}
[CATransaction commit];
return;
}
I would be able to track down the problem if I could reproduce it when debugging but it only seems to occur when built for ad-hoc. Thanks!
Edit: Using the simulator, I have tracked down the problem to a EXC_BAD_ACCESS at this line
[layersToRemove enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
I ended up working out the problem. In my compiler settings, somehow, ARC wasn't enabled for Ad-Hoc builds resulting in weird behaviour. Before I worked this out, allocating the __block variable worked because in non-ARC environments, __block variables are not retained automatically.
Changed compiler settings so that all builds use ARC and everything was fixed.