简体   繁体   English

iOS10 Open Beta-保存时iOS核心数据崩溃

[英]iOS10 Open Beta - iOS Core Data Crash on save

I am assuming it is ok to post beta iOS10 issues here, since it is an open beta. 我假设可以在此处发布beta iOS10问题,因为它是开放测试版。 The apple forums don't come close to the help one gets on Stackoverflow. 苹果论坛离Stackoverflow还差得远。

Since the update to iOS10, our users are getting a constant crash when saving the managedObjectContext in CoreData. 自从iOS10更新以来,我们的用户在将ManagedObjectContext保存在CoreData中时经常崩溃。

This is something that has worked flawlessly since iOS 5. 自iOS 5起,此功能就可以完美运行。

It only happens on the 64 bit version of iOS10. 它仅在iOS10的64位版本上发生。 The 32 bit version works fine. 32位版本工作正常。

Here is my simple save code snip: 这是我简单的保存代码片段:

    [self.managedObjectContext performBlockAndWait:^{
    NSError *error;
    if (![self.managedObjectContext save:&error])
    {
       NSLog(@"\n\nerror in save 1 %@\n\n", error);
    }
}];

[self.managedObjectContext performBlock:^{
    NSError *error;
    if (![_privateWriterContext save:&error])
    {
       NSLog(@"\n\nerror in save 2 %@\n\n", error);
    }
}];

(Above NSLog reports nothing, as it works in simulator). (在NSLog上面没有报告任何内容,因为它在模拟器中有效)。

This only fails on a 64bit device. 这仅在64位设备上失败。 I cannot replicate on the simulator. 我无法在模拟器上复制。 I also cannot replicate in debug on a device due to issues with my only 64 bit device not connecting to Xcode correctly. 由于唯一的64位设备无法正确连接到Xcode,因此我也无法在设备上的调试中进行复制。 So I am a bit stuck. 所以我有点卡住。

Below is a sample stack trace reported from a user: 以下是用户报告的示例堆栈跟踪:

    Incident Identifier: 7A8DD23B-48A2-4ABF-88E7-67F1E6CDA8D5
CrashReporter Key:   5454e7c7b99a94cd75b6adfa8334bbdf10b859eb
Hardware Model:      iPhone8,1
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]



Date/Time:           2016-07-20 22:23:00.1429 -0400
Launch Time:         2016-07-20 22:21:30.6058 -0400
OS Version:          iPhone OS 10.0 (14A5309d)
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000985e4beb8
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libobjc.A.dylib                 0x00000001850e6eb0 objc_msgSend + 16
1   CoreFoundation                  0x0000000185a76740 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20 (CFNotificationCenter.c:650)
2   CoreFoundation                  0x0000000185a75e44 _CFXRegistrationPost + 400 (CFNotificationCenter.c:164)
3   CoreFoundation                  0x0000000185a75bc0 ___CFXNotificationPost_block_invoke + 60 (CFNotificationCenter.c:1031)
4   CoreFoundation                  0x0000000185ae40cc -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1504 (CFXNotificationRegistrar.m:163)
5   CoreFoundation                  0x00000001859b9484 _CFXNotificationPost + 376 (CFNotificationCenter.c:1028)
6   Foundation                      0x000000018644e9dc -[NSNotificationCenter postNotificationName:object:userInfo:] + 68 (NSNotification.m:482)
7   CoreData                        0x0000000187e1dbf4 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postContextDidSaveNotificationWithUserInfo:] + 880 (NSManagedObjectContext.m:7381)
8   CoreData                        0x0000000187dabb4c -[NSManagedObjectContext(_NSInternalAdditions) _didSaveChanges] + 2156 (NSManagedObjectContext.m:5827)
9   CoreData                        0x0000000187d98570 -[NSManagedObjectContext save:] + 3440 (NSManagedObjectContext.m:1532)
10  App                             0x000000010008db34 __29-[RPSAppDelegate saveContext]_block_invoke227 + 52 (RPSAppDelegate.m:338)
11  CoreData                        0x0000000187e17c68 developerSubmittedBlockToNSManagedObjectContextPerform + 168 (NSManagedObjectContext.m:3529)
12  libdispatch.dylib               0x0000000185525784 _dispatch_client_callout + 16 (object.m:455)
13  libdispatch.dylib               0x000000018552a330 _dispatch_main_queue_callback_4CF + 1000 (inline_internal.h:2421)
14  CoreFoundation                  0x0000000185a8a0cc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1793)
15  CoreFoundation                  0x0000000185a87cb8 __CFRunLoopRun + 1660 (CFRunLoop.c:3004)
16  CoreFoundation                  0x00000001859b78d8 CFRunLoopRunSpecific + 444 (CFRunLoop.c:3113)
17  GraphicsServices                0x00000001873be198 GSEventRunModal + 180 (GSEvent.c:2245)
18  UIKit                           0x000000018b9617c8 -[UIApplication _run] + 664 (UIApplication.m:2651)
19  UIKit                           0x000000018b95c534 UIApplicationMain + 208 (UIApplication.m:4088)
20  App                             0x000000010008c138 main + 152 (main.m:27)
21  libdyld.dylib                   0x00000001855585b8 start + 4

Thank you for any ideas. 谢谢您的任何想法。

You are saving _privateWriterContext in a block call of managedObjectContext . 您正在将_privateWriterContext保存在managedObjectContext的块调用中。 This is not allowed. 这是不允许的。 The fact that it worked before is a "false positive". 它以前起作用的事实是“误报”。

Instead, you should always only use at the same context that creates the block. 相反,您应该始终仅在与创建块相同的上下文中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM