I have an app, which users are reporting to crash at random times. All crashes have the same stack
0 CoreFoundation TAGPBIvarClearUInt32 (in SPONTAN) + 11
1 libobjc.A.dylib _mh_execute_header (in SPONTAN) + 15567
2 CoreFoundation TAGPBIvarClearSFixed64 (in SPONTAN) + 13
3 Foundation -[AdvancedPriceViewController newAP:] (in SPONTAN) (AdvancedPriceViewController.m:68) + 110325
4 SPONTAN +[TrStart isJSONTrStart:] (in SPONTAN) + 77
5 SPONTAN __65-[MintRequestWorker processPreviousLoggedRequestsAsyncWithBlock:]_block_invoke_2 (in SPONTAN) + 397
6 SPONTAN __58-[FileRepository readLoggedExceptionsWithCompletionBlock:]_block_invoke (in SPONTAN) + 281
7 libdispatch.dylib _mh_execute_header (in SPONTAN) + 6195
8 libdispatch.dylib -[FirstViewController viewDidLoad] (in SPONTAN) (FirstViewController.m:56) + 84257
9 libdispatch.dylib -[FirstViewController viewDidAppear:] (in SPONTAN) (FirstViewController.m:80) + 84769
10 libsystem_pthread.dylib _mh_execute_header (in SPONTAN) + 3027
11 libsystem_pthread.dylib _mh_execute_header (in SPONTAN) + 2712
This may look fine, but when I look at level 3, 8 and 9, the code makes no sense anymore.
3 Foundation -[AdvancedPriceViewController newAP:] (in SPONTAN) (AdvancedPriceViewController.m:68) + 110325
Line 68: NSMutableArray *arrayOfIndexPaths = [[NSMutableArray alloc] init];
8 libdispatch.dylib -[FirstViewController viewDidLoad] (in SPONTAN) (FirstViewController.m:56) + 84257
Line 56: [[SelectCity titleLabel] setFont:[UIFont fontWithName:@"Avenir" size:15]];
9 libdispatch.dylib -[FirstViewController viewDidAppear:] (in SPONTAN) (FirstViewController.m:80) + 84769
Line 80: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
The error is a NSRangeException
*** -[__NSCFConstantString substringToIndex:]: Index 2147483647 out of bounds; string length 0
Can anyone tell me what's going on here?
Search your source for usage of the selector substringToIndex:
. I'm not familiar with the AdvancedPriceViewController
class; if it's yours, you'll probably find a substringToIndex:
in [AdvancedPriceViewController newAP:]
where you've constructed an NSRange
object with -1
. When -1
is converted to a uint32
, it'll appear as 2147483647
or MAX_INT
.