Why the stack trace of -componentsSeparatedByString:
is
different between crashes?
Because things are failing in different ways. Let’s look at the backtraces of your five crashes in order.
Thread 13 name:
Thread 13 Crashed:
0 libobjc.A.dylib … cache_t::insert(objc_selector*, void (*)(), objc_object*) + 244 (objc-cache.mm:901)
1 libobjc.A.dylib … lookUpImpOrForward + 664 (objc-runtime-new.mm:7435)
2 libobjc.A.dylib … _objc_msgSend_uncached + 68 (:-1)
3 CoreFoundation … __exceptionPreprocess + 124 (NSException.m:241)
4 libobjc.A.dylib … objc_exception_throw + 60 (objc-exception.mm:356)
5 CoreFoundation … -[__NSArrayM insertObject:atIndex:] + 1292 (NSArrayM.m:164)
6 Foundation … -[NSString componentsSeparatedByString:] + 160 (NSString.m:623)
7 Pendo … +[PNDDiskBufferHelper getObjectsFromData:] + 144
In this crash NSArray
has detected a problem and is trying to throw a language exception. That’s got halfway through the process before crashing in the Objective-C runtime due to a memory corruption issue.
Thread 13 name:
Thread 13 Crashed:
0 CoreFoundation … -[__NSArrayM insertObject:atIndex:].cold.1 + 16 (NSArrayM.m:168)
1 CoreFoundation … -[__NSArrayM insertObject:atIndex:] + 1680 (NSArrayM.m:168)
2 Foundation … -[NSString componentsSeparatedByString:] + 160 (NSString.m:623)
3 Pendo … +[PNDDiskBufferHelper getObjectsFromData:] + 144
In this crash NSArray
has detected a problem and trapped. It’s hard to say exactly what’s causing this due to inlining but, if I had to guess, it’s because the index is out of bounds.
Last Exception Backtrace:
0 CoreFoundation … __exceptionPreprocess + 164 (NSException.m:202)
1 libobjc.A.dylib … objc_exception_throw + 60 (objc-exception.mm:356)
2 CoreFoundation … _CFThrowFormattedException + 108 (CFObject.m:2235)
3 CoreFoundation … -[__NSArrayM insertObject:atIndex:].cold.1 + 52 (NSArrayM.m:164)
4 CoreFoundation … -[__NSArrayM insertObject:atIndex:] + 908 (NSArrayM.m:164)
5 Foundation … -[NSString componentsSeparatedByString:] + 160 (NSString.m:599)
In this crash NSArray
has successfully managed to throw the exception. I’m fairly confident that the exception is complaining that the object being inserted is nil
.
Thread 15 name:
Thread 15 Crashed:
0 libobjc.A.dylib … cache_t::insert(objc_selector*, void (*)(), objc_object*) + 244 (objc-cache.mm:934)
1 libobjc.A.dylib … lookUpImpOrForward + 664 (objc-runtime-new.mm:7503)
2 libobjc.A.dylib … _objc_msgSend_uncached + 68 (:-1)
3 CoreFoundation … -[__NSArrayM insertObject:atIndex:] + 1288 (NSArrayM.m:164)
4 Foundation … -[NSString componentsSeparatedByString:] + 160 (NSString.m:622)
5 Pendo … +[PNDDiskBufferHelper getObjectsFromData:] + 144
This is very similar to crash 1, albeit with a slightly different backtrace probably due to a different object being corrupted.
Thread 13 name:
Thread 13 Crashed:
0 CoreFoundation … -[__NSArrayM insertObject:atIndex:].cold.2 + 16 (NSArrayM.m:254)
1 CoreFoundation … -[__NSArrayM insertObject:atIndex:] + 988 (NSArrayM_Common.h:254)
2 Foundation … -[NSString componentsSeparatedByString:] + 160 (NSString.m:599)
3 Pendo … +[PNDDiskBufferHelper getObjectsFromData:] + 144
The backtrace here is a bit weird because of inlining, but I believe that the crash is because some core code within NSArray
was unable to allocate memory for the array. That is, malloc
failed. Either your process has run out of address space, or the heap is corrupted. Given the other crashes, I suspect it’s the latter.
What do you think if we rewrite apple -componentsSeparatedByString:
with our own implementation
I think you’ll start getting similar crash reports from your own code. Unless you think that -componentsSeparatedByString:
itself is corrupting memory — which seems unlikely because it’s pretty darned battle hardened — the root cause of this problem is some other memory corruption issue, and changing out this implementation won’t affect that.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"