I have an iOS customer reporting a consistent, crashing bug, with the following stack:
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000018eb741a8 semaphore_wait_trap + 8
1 libdispatch.dylib 0x000000018ea5f7ec _dispatch_semaphore_wait_slow + 216
2 Scruff 0x00000001003bf0fc -[TMCache setObject:forKey:] (TMCache.m:332)
3 Scruff 0x00000001000c2a40 __44-[MSSProfileStreamingDataSource downloaded:]_block_invoke (MSSProfileStreamingDataSource.m:532)
4 libdispatch.dylib 0x000000018ea4d200 _dispatch_call_block_and_release + 24
5 libdispatch.dylib 0x000000018ea4d1c0 _dispatch_client_callout + 16
6 libdispatch.dylib 0x000000018ea51d6c _dispatch_main_queue_callback_4CF + 1000
7 CoreFoundation 0x000000018fb71f2c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8 CoreFoundation 0x000000018fb6fb18 __CFRunLoopRun + 1660
9 CoreFoundation 0x000000018fa9e048 CFRunLoopRunSpecific + 444
10 GraphicsServices 0x0000000191521198 GSEventRunModal + 180
11 UIKit 0x0000000195a77818 -[UIApplication _run] + 684
12 UIKit 0x0000000195a72550 UIApplicationMain + 208
13 Scruff 0x00000001000cc9b8 main (main.m:22)
14 libdyld.dylib 0x000000018ea805b8 start + 4
Can someone explain exactly what semaphore_wait_trap
is doing, and in what conditions it would trigger an EXEC_CRASH
? SIGKILL
means someone else triggered a kill - does this mean that iOS is killing the app because the semaphore wait took too long?
Here is the code in question for TMCache
, which is the Tumblr cache library for iOS:
- (void)setObject:(id <NSCoding>)object forKey:(NSString *)key
{
if (!object || !key)
return;
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[self setObject:object forKey:key block:^(TMCache *cache, NSString *key, id object) {
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
#if !OS_OBJECT_USE_OBJC
dispatch_release(semaphore);
#endif
}
Line 332 is the final line of the method, and OS_OBJECT_USE_OBJC
is true, so I assume this crash is because of dispatch_semaphore_wait
.