8

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];
arunjos007
  • 4,105
  • 1
  • 28
  • 43
  • 1
    Please put some relevant code. – nynohu Jan 10 '17 at 07:46
  • @nynohu Its a huge project which contains 100+ xib files and controllers, I don't know which chunk of code causing this issue. But still this crash have reported by crashlytics. – arunjos007 Jan 10 '17 at 08:31
  • You do not know which snippet is related with this problem, do you? – nynohu Jan 10 '17 at 08:34
  • @nynohu, I don't know, but from crash thread details it may be related to local notification. Did you got any idea from the stacktrace details? – arunjos007 Jan 10 '17 at 08:55
  • its probably related to `NSLocalNotification` so check your implementation of notification handling while the app is in foreground , background and its not running – MohyG Feb 20 '17 at 09:23
  • In my testings its working perfectly with all scenarios – arunjos007 Feb 20 '17 at 09:25
  • 1
    seems like serialization issue, see http://stackoverflow.com/questions/4637179/uilocalnotification-crash – paiv Feb 20 '17 at 11:11
  • If it has to do with your local notifications, could you at least post the code you use to schedule and present notifications? – Pierce Feb 20 '17 at 23:00
  • Looks like it's crashing when someone (probably the system) tries to cancel the notification. It could be some non-coding compliant data (see above), no more memory, a race condition or something else. To narrow it down i'd try to run my notifications related tests on a relase build or and optimized debug build. It will of course not allow proper debug, but having the exceptions breakpoint set you might be able to inspect the object on frame 3 on that stack trace. – Mihai Timar Feb 21 '17 at 09:24

0 Answers0