在 NSManagedObjectContext -save 中调试 SIGABRT:
从 NSManagedObjectContext -save: 内部收到此消息:
断言失败:(_Unwind_SjLj_Resume() 无法返回),函数 _Unwind_SjLj_Resume,文件 /SourceCache/libunwind/libunwind-24.1/src/Unwind-sjlj.c,第 326 行。
程序接收信号:“SIGABRT”。
警告:无法读取符号 /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (未找到文件)。
当我删除一个与 Run 具有一对多关系的 Experiment 对象时,会发生这种情况,该对象与 Sample 具有一对多关系,而 Sample 与 Data 具有一对一关系。实验还与页面具有一对多关系,而页面与显示具有一对多运行关系。我提到这一点是为了指出图表的周期性。以下是模型的简化图:
实验是与用户交互的顶级实体。一个实验包含多个运行对象。运行是从特定时间开始并在稍后时间结束的数据集合。由于可以同时从多个来源收集数据,因此每次运行的每个来源都有一个样本。实验包含数据,需要查看这些数据并与之交互。因此,每个实验都有一定数量的页面对象,并且每个页面包含一定数量的显示(例如,图表、仪表)。显示配置为显示属于实验的运行的某些子集。因此,虽然一个实验可能包含数十个运行,但其页面之一一次只会显示其中的几个运行。显示实体维护该列表。显示不是视图。视图将引用 Display 对象并收到 Display 对象更改的通知。
我一直在使用删除规则,但现在已切换到“无操作”删除规则,并结合所有这些类的 -prepareForDeletion 方法。这个改变没有什么区别。在这两种情况下,错误消息是相同的。
有趣的是,当我重新启动应用程序时,所有标记为删除的对象都已被删除。
此外,如果实验没有 Run 对象,则删除不会发生。就此而言,从实验中删除单个运行也是可行的。
我希望有人见过这样的事情,并能就导致这种情况的原因提供建议。或者,如果有人对如何获取适用于 iOS 4.2.1 的 libXcodeDebuggerSupport.dylib 有建议,这也可能会有所帮助。
更新:我遵循了发现的建议此处 并能够让 Xcode 找到适用于 iOS 4.2.1 的 libXcodeDebuggerSupport.dylib。但这对诊断问题毫无帮助——问题仍然存在。
更新2:阅读了一些内容并下载了 unwind-sjlj.c 的版本后,我似乎正在处理类似未捕获异常的问题。我不知道这对我有什么帮助...
更新 3: 感谢堪察加半岛,我做了一些我可能应该在几天前做的事情:打开“停止 Objective-C 异常”。这让我看到对已删除对象的引用仍然被保留 - 更糟糕的是,键值对已删除对象进行观察。解决这个已解决的问题后,我能够恢复使用删除规则而不是 -prepareForDeletion 方法。
From inside NSManagedObjectContext -save: I am getting this message:
Assertion failed: (_Unwind_SjLj_Resume() can't return), function _Unwind_SjLj_Resume, file /SourceCache/libunwind/libunwind-24.1/src/Unwind-sjlj.c, line 326.
Program received signal: “SIGABRT”.
warning: Unable to read symbols for
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1
(8C148)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib
(file not found).
This happens when I delete an Experiment object with to-many with Run which has to-many with Sample which has to-one with Data. Experiment also has to-many with Page which has to-many with Display which has to-many to Run. I mention this to point out the cyclical nature of the graph. Here is a simplified graph of model:
An Experiment a top level entity with which the user interacts. An Experiment contains multiple Run objects. A Run is a collection of data starting at a particular time and ending at a later time. Since data can be collected from multiple sources simultaneously, there is a Sample for each source for each Run. An Experiment contains data and this data needs to be viewed and interacted with. So, each Experiment has some number of Page objects and each Page contains some number of Displays (e.g., graphs, meters). A Display is configured to display some subset of the Runs that belong to the Experiment. So, while an Experiment may contains dozens of Runs, one of its Pages will only display a few of those Runs at a time. The Display entity maintains this list. A Display is not a view. A view will reference a Display object and be notified of changes to the Display object.
I had been using Delete Rules but have now switched to "No Action" delete rules in combination with -prepareForDeletion methods for all of these classes. This change made no difference. In both cases, the error message is the same.
Interestingly, when I relaunch the app, all the objects that were marked for deletion have been deleted.
Also, if an Experiment has no Run objects, then deletion works without incidence. For that matter, deleting a single Run from an Experiment also works.
I am hoping that someone has seen something like this and can offer advice on what would cause this. Or, if someone has advice on how to get libXcodeDebuggerSupport.dylib for iOS 4.2.1, that might also be helpful.
Update: I followed advice found here and was able to get Xcode to find libXcodeDebuggerSupport.dylib for iOS 4.2.1. But this did not help at all in diagnosing problem - which persists.
Update 2: After reading a bit and downloading a version of unwind-sjlj.c, it seems that I am dealing with something like an uncaught exception. I am not sure how this helps me...
Update 3: Thanks to Kamchatka, I did something I probably should have done a few days ago: turned on "Stop on Objective-C Exceptions". This allowed me to see that a reference to a deleted object was still being held - and, worse, was key-value observing the deleted object. Fixing this fixed problem and I was able to revert to using delete rules rather than -prepareForDeletion methods.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该尝试激活“Run > Stop on Objective-C exception”。它使我能够找到对对象的访问变成错误的地方,这是问题的根本原因。
You should try to activate "Run > Stop on Objective-C exception". It allowed me to find the place where there was an access to an object turned into fault which was the root cause of the problem.