核心数据Malloc错误 [英] Core Data Malloc Errors
问题描述
我注意到我在我的应用程序中的随机点有几个错误。我有2个错误,双自由和不正确的校验和释放对象。堆栈跟踪的双自由错误。任何人都可以提供任何洞察力?它发生在我的代码中的一个调用,只是设置属性到 NSNumber
,所以我不明白为什么它这样做!
I've noticed I'm getting a few errors at random points in my app. I've had 2 errors, "double free" and "incorrect checksum for freed object". Heres the stack trace of a "double free" error. Can anyone provide any insight? It's happening on a call in my code that just sets an attribute to an NSNumber
so I can't understand why it's doing it!
myObject.numberAttr = [NSNumber numberWithInt:[dateComponents day]];
随机触发(不总是会发生):
#0 0x9585b072 in malloc_error_break
#1 0x9585c218 in szone_error
#2 0x9585c34d in free_tiny_botch
#3 0x01c5e064 in _PFDeallocateObject
#4 0x01c97e2b in -[NSManagedObject(_NSInternalMethods) _setLastSnapshot__:]
#5 0x01c97a0d in -[NSManagedObjectContext(_NSInternalChangeProcessing) _establishEventSnapshotsForObject:]
#6 0x01c97866 in _PFFastMOCObjectWillChange
#7 0x01c976c5 in _PF_ManagedObject_WillChangeValueForKeyIndex
#8 0x01c97525 in _sharedIMPL_setvfk_core
#9 0x01c9b827 in _svfk_5
非常感谢,
Michael
推荐答案
事实证明,这是一个线程问题与我的托管对象上下文。我在主线程上创建它,并在我的后台线程上使用它。但是,看起来上下文必须在1个线程内创建和使用。希望这有助于任何人谁可能遇到这个问题作为调试信息不是很清楚!
I figured it out! It turns out that it was a threading issue with my managed object context. I was creating it on the main thread and using it on my background thread. However it would seem that the context has to be created and used all within 1 thread. Hope this helps anyone else who may come across this issue as the debugging information wasn't very clear!
这篇关于核心数据Malloc错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!