I got a strange EXC_BAD_ACCESS crash inside Foundation's _NSXPCSerializationAddData
method. It happens quite often, but I cannot get any meaningful information out of stack trace.
The only hint is that crash happens inside com.apple.UNSNotificationSchedulerConnection
thread, but I have no idea what is it about. I have used Local Notification to alert user, is this crash related to NSLocalNotification
? Can someone help?
Stacktrace from Crashlytics:
Crashed: com.apple.UNSNotificationSchedulerConnection
0 libsystem_platform.dylib 0x2491e164 _platform_memmove$VARIANT$CortexA9 + 40
1 Foundation 0x25351825 _NSXPCSerializationAddData + 156
2 Foundation 0x25351825 _NSXPCSerializationAddData + 156
3 UIKit 0x297f78f3 -[UIConcreteLocalNotification encodeWithCoder:] + 526
4 Foundation 0x253418b7 -[NSXPCEncoder _encodeObject:] + 618
5 Foundation 0x253a2d83 -[NSXPCEncoder _encodeArrayOfObjects:forKey:] + 210
6 Foundation 0x253418b7 -[NSXPCEncoder _encodeObject:] + 618
7 Foundation 0x25341ceb encodeInvocationArguments + 306
8 Foundation 0x25341a47 -[NSXPCEncoder encodeInvocation:] + 362
9 Foundation 0x253418b7 -[NSXPCEncoder _encodeObject:] + 618
10 Foundation 0x254ecb0f -[NSXPCConnection _sendInvocation:withProxy:remoteInterface:withErrorHandler:timeout:userInfo:] + 2158
11 Foundation 0x254ec22b -[NSXPCConnection _sendInvocation:withProxy:remoteInterface:] + 46
12 Foundation 0x25340c47 -[_NSXPCDistantObject forwardInvocation:] + 82
13 CoreFoundation 0x24bf2d83 ___forwarding___ + 350
14 CoreFoundation 0x24b1e238 _CF_forwarding_prep_0 + 24
15 UserNotificationServices 0x262a1c67 __107-[UNSNotificationSchedulerConnection cancelScheduledLocalNotifications:forBundleIdentifier:withCompletion:]_block_invoke + 62
16 libdispatch.dylib 0x2475d823 _dispatch_call_block_and_release + 10
17 libdispatch.dylib 0x2476a423 _dispatch_queue_drain$VARIANT$mp + 1758
18 libdispatch.dylib 0x24769a61 _dispatch_queue_invoke$VARIANT$mp + 284
19 libdispatch.dylib 0x2476c5e9 _dispatch_root_queue_drain + 1560
20 libdispatch.dylib 0x2476bfcd _dispatch_worker_thread3 + 96
21 libsystem_pthread.dylib 0x24921b29 _pthread_wqthread + 1024
22 libsystem_pthread.dylib 0x24921718 start_wqthread + 8
Please find the code to schedule notification,
//Appdelgate.h file
@property (strong, nonatomic) UILocalNotification *alarm;
//AppDelegate.m file
self.alarm = [[UILocalNotification alloc] init];
self.alarm.timeZone = [NSTimeZone defaultTimeZone];
self.alarm.soundName = UILocalNotificationDefaultSoundName;
//MainController.m file
[AppDelegate application].alarm.fireDate = alarmDueTime;
NSDictionary *userInfoDictionary = @ {
@"id" :@1
};
[AppDelegate application].alarm.userInfo = userInfoDictionary;
[AppDelegate application].alarm.alertBody = localNotificationMessage;
[[UIApplication sharedApplication] scheduleLocalNotification:[AppDelegate application].alarm];