mergeChangesFromContextDidSaveNotification期间核心数据崩溃

时间:2016-07-27 08:48:40

标签: core-data exc-bad-access

我在Core Data私有/内部方法中随机发生了罕见的崩溃。

我的设置:

  • 两个NSPSC:mainPSC和importPSC
  • 附加到importPSC的MOC运行 背景和执行保存
  • 另一个对象听 DidSaveNotification然后将importerMOC与mainMOC合并 (附于mainPSC)

这完全在iOS 9.3上。 这是在主线程上运行的代码(它来自我的库RTCoreDataStack):

13:47:05,031 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deployment.subunit."Test.ear"."TestWeb.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."Test.ear"."TestWeb.war".PARSE: Failed to process phase PARSE of subdeployment "TestWeb.war" of deployment "Test.ear"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
Caused by: java.lang.IllegalArgumentException: Given parent is not an ancestor of this virtual file
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:116) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:122) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.vfs.VirtualFile.getPathNameRelativeTo(VirtualFile.java:110) [jboss-vfs-3.1.0.Final.jar:3.1.0.Final]
    at org.jboss.as.web.deployment.TldParsingDeploymentProcessor.processTlds(TldParsingDeploymentProcessor.java:107)
    at org.jboss.as.web.deployment.TldParsingDeploymentProcessor.deploy(TldParsingDeploymentProcessor.java:83)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    ... 5 more

我在崩溃报告中使用各种代码(模拟器上的EXC_I386_GPFLT或设备上的SIGSEGV)获得EXC_BAD_ACCESS。这是一个例子:

[self.mainManagedObjectContext performBlock:^{
    [self.mainManagedObjectContext mergeChangesFromContextDidSaveNotification:notification];
}];

1 个答案:

答案 0 :(得分:0)

当你使用KVO来监控NSMO的财产时,一个善良的灵魂指出了这种崩溃的可能性。

起初我尝试用Facebook的KVOController替换我自己的KVO代码,但它没有帮助。然后我完全移除了KVO,崩溃消失了。

因此,第一个结论是当KVO设置在一个对象上时会发生崩溃,该对象在DidSaveNotification 上发生合并期间从商店中删除。

此外,对于我的情况 - 它不仅仅是KVO本身,而且还有I KVO-ed对象被添加到设置为property(assign)的NSSet这一事实。我目前正在测试KVO + strong参考。