On iOS 7, I have two viewControllers that my app switches between using a Navigation Controller. The 2nd VC contains a UICollectionView
and I've subclassed UICollectionViewCell
.
When I turn OFF Guard Malloc
my app successfully executes the following scenario:
- Display VC1, where I define some variable number of cells that will
populate the
UICollectionView
in VC2 - Display VC2, including display
of the number of custom
UICollectionViewCell
s I defined in VC1 - Display VC1, make no change to the number of cells
- Display VC2, including the same number of custom cells that were displayed in step 2.
When I turn Guard Malloc
ON, my app crashes in the middle of step 4. Here's the stack trace:
2013-11-23 18:32:29.568 SongSketchbookTemp2[55597:70b] >>> Entering -[TPXMixViewController collectionView:layout:sizeForItemAtIndexPath:] >>>
2013-11-23 18:32:29.569 SongSketchbookTemp2[55597:70b] <<< Leaving -[TPXMixViewController collectionView:layout:sizeForItemAtIndexPath:] <<<
2013-11-23 18:32:29.570 SongSketchbookTemp2[55597:70b] >>> Entering -[TPXMixViewController collectionView:layout:sizeForItemAtIndexPath:] >>>
2013-11-23 18:32:29.570 SongSketchbookTemp2[55597:70b] <<< Leaving -[TPXMixViewController collectionView:layout:sizeForItemAtIndexPath:] <<<
2013-11-23 18:32:29.571 SongSketchbookTemp2[55597:70b] >>> Entering -[TPXMixViewController collectionView:layout:sizeForItemAtIndexPath:] >>>
2013-11-23 18:32:29.572 SongSketchbookTemp2[55597:70b] <<< Leaving -[TPXMixViewController collectionView:layout:sizeForItemAtIndexPath:] <<<
2013-11-23 18:32:29.573 SongSketchbookTemp2[55597:70b] >>> Entering -[TPXMixViewController collectionView:layout:insetForSectionAtIndex:] >>>
2013-11-23 18:32:29.574 SongSketchbookTemp2[55597:70b] <<< Leaving -[TPXMixViewController collectionView:layout:insetForSectionAtIndex:] <<<
2013-11-23 18:32:29.578 SongSketchbookTemp2[55597:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithCapacity:]: capacity (1184366560) is ridiculous'
*** First throw call stack:
(
0 CoreFoundation 0x025fba14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x023798b6 objc_exception_throw + 44
2 CoreFoundation 0x025d32be -[__NSPlaceholderDictionary initWithCapacity:] + 286
3 UIKit 0x014a82d5 -[UICollectionView _updateVisibleCellsNow:] + 2123
4 UIKit 0x014acb5f -[UICollectionView layoutSubviews] + 265
5 UIKit 0x00eec367 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
6 libobjc.A.dylib 0x0238b81f -[NSObject performSelector:withObject:] + 70
7 QuartzCore 0x0021a23a -[CALayer layoutSublayers] + 148
8 QuartzCore 0x0020e024 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
9 QuartzCore 0x0020de90 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
10 QuartzCore 0x001754a2 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
11 QuartzCore 0x0017682d _ZN2CA11Transaction6commitEv + 393
12 QuartzCore 0x00233390 +[CATransaction flush] + 52
13 UIKit 0x00e7d46b _UIApplicationHandleEventQueue + 12967
14 CoreFoundation 0x02584cdf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
15 CoreFoundation 0x0258466b __CFRunLoopDoSources0 + 235
16 CoreFoundation 0x025a173e __CFRunLoopRun + 910
17 CoreFoundation 0x025a0f63 CFRunLoopRunSpecific + 467
18 CoreFoundation 0x025a0d7b CFRunLoopRunInMode + 123
19 GraphicsServices 0x03b4f2c2 GSEventRunModal + 192
20 GraphicsServices 0x03b4f0e9 GSEventRun + 104
21 UIKit 0x00e7faab UIApplicationMain + 1225
22 SongSketchbookTemp2 0x00002e0d main + 141
23 libdyld.dylib 0x037eb70d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
In the run above I defined 3 cells to be displayed. The three calls to sizeForItemAtIndexPath
correspond to the three cells to be (re)displayed in step 4. As you can see, the app calls and returns from insetForSectionAtIndex
and then crashes on a mysterious call to [NSPlaceholderDictionary initWithCapacity]
.
Here's my cellForItemAtIndexPath
: method:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@">>> Entering %s >>>", __PRETTY_FUNCTION__);
TPXFilePlayerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"filePlayerCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor clearColor];
[cell setTag:[indexPath item]];
[[cell slider]setTag:[indexPath item]];
NSNumber *newGain = 0;
if ([[self openSketchbook]mixerGainSettings]) {
if ([self.openSketchbook.mixerGainSettings count] >= [indexPath item]+1) {
newGain = self.openSketchbook.mixerGainSettings[[indexPath item]];
[[cell slider]setValue:[newGain floatValue]];
}
}
NSLog(@"<<< Leaving %s <<<", __PRETTY_FUNCTION__);
return cell;
}
What could be causing this or how might I troubleshoot this?