CoreStore: iOS 10: Sectioned ListMonitor crashing with EXC_BAD_ACCESS

Since upgrading to CoreStore v2.1.0 and Xcode 8 I’m getting a repeatable crash whenever I try to display a view that is backed by a sectioned ListMonitor on the iOS 10 simulator (it’s fine on iOS 9):

screen shot 2016-09-22 at 17 43 32 screen shot 2016-09-22 at 17 44 21

If I change the monitor to a non-sectioned list it’s fine.

I’ve tried enabling Zombie Objects but nothing helpful is logged.

Also, why is CoreStore warning me that I’m overwriting a Where clause? Isn’t that the point of refetch() anyway?

I’m at a bit of a loss at how to fix this one, any help would be much appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 44 (21 by maintainers)

Commits related to this issue

Most upvoted comments

Yep, that fixes it. 👍

Oh boy 😅 @a13xb Thanks for testing this out! I’ll try to get a fix up in the next update

My hunch was correct, but I hit a roadblock. First, using @jamesbebbington’s test project, go to CoreStoreFetchRequest.swift and comment out the override for affectedStores

// MARK: - CoreStoreFetchRequest

// Bugfix for NSFetchRequest messing up memory management for `affectedStores`
// http://stackoverflow.com/questions/14396375/nsfetchedresultscontroller-crashes-in-ios-6-if-affectedstores-is-specified
internal final class CoreStoreFetchRequest: NSFetchRequest {

//    @objc
//    override var affectedStores: [NSPersistentStore]? {
//        
//        get { return super.affectedStores }
//        set { super.affectedStores = newValue }
//    }
}

This fixed the crash for me. Here’s the problem: doing this breaks CoreStore’s unit tests and demo app. The difference I can think of is that the test project imports CoreStore as a Cocoapod, and CoreStore’s test cases and demo app imports it as a framework. There must be a Cocoapod compiler setting somewhere that somehow fixes the bug that override var affectedStores was trying to fix.

I’ll continue investigating this tomorrow, but if you find other hints please do share. In the meantime, you can try commenting out the code above.

I might have a hunch on why this is happening. Let me test for a while

Ok, I think I can reproduce the issue: In CountriesTableViewController change the monitorSectionedList part to:

    let countries: ListMonitor<Country> = CoreStore.monitorSectionedList(
        From(Country),
        SectionBy("continent.name"),
        OrderBy(.Ascending("continent.name")),
        Tweak { (fetchRequest) -> Void in
            fetchRequest.fetchBatchSize = 20
        }
    )

Crashes every time.