I'm getting an intermittent bug that is proving very hard to debug.
I'm getting the following error from the following method
EXC_BAD_ACCESS(code=1, address=0x10) on Core Data Fetch
class func getAll(context: NSManagedObjectContext) -> [Tag] {
var returnValue: [Tag] = []
do {
let fetchRequest = NSFetchRequest(entityName: Tag.entityName())
returnValue = try context.executeFetchRequest(fetchRequest) as! [Tag]
} catch {
}
return returnValue
}
The bug is extermely intermittent, and is only happening on every few 100 sessions, but is appearing frequent enough that I need to deal with it. The code breaks on the line returnvalue = try context.execute...
- From debugging, my
fetchRequestis notnil - my
contextis notnil - returnValue has a default value of an empty array
- my backgroundContext is running on a background thread
I've turned on the NSZombieFlag to try to see if some memory is deallocated somewhere and then being accessed, but I'm stumped on what is causing this. Any ideas or insight would be much appreciated.