Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid concurrent access to managed object calling 'release'; Stacktrace #25

Open
am33t opened this issue May 31, 2016 · 0 comments
Open

Comments

@am33t
Copy link

am33t commented May 31, 2016

Hi i'm getting following warnings in my code.

2016-05-31 17:13:16.988 ABC-iPhone[5183:2764409] Invalid concurrent access to managed object calling 'release'; Stacktrace: (
    0   ABC-iPhone                   0x0000000100874ad0 ValidateConcurrency + 248
    1   ABC-iPhone                   0x0000000100874698 CustomSubclassRelease + 32
    2   ABC-iPhone                   0x00000001004c6710 _TFC17ABC_iPhone10SWCProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 136
    3   ABC-iPhone                   0x00000001003734c0 _TFC17ABC_iPhone16SWCPickedProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 80
    4   ABC-iPhone                   0x0000000100373548 _TToFC17ABC_iPhone16SWCPickedProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 76
    5   CoreData                            0x00000001845505cc <redacted> + 172
    6   CoreData                            0x000000018454f0dc <redacted> + 180
    7   CoreData                            0x00000001845e2490 <redacted> + 784
    8   CoreData                            0x00000001845e2a50 <redacted> + 348
    9   CoreData                            0x00000001845e4d8c <redacted> + 108
    10  libdispatch.dylib                   0x0000000101e41a3c _dispatch_client_callout + 16
    11  libdispatch.dylib                   0x0000000101e52040 _dispatch_barrier_sync_f_slow_invoke + 736
    12  libdispatch.dylib                   0x0000000101e41a3c _dispatch_client_callout + 16
    13  libdispatch.dylib                   0x0000000101e474e4 _dispatch_main_queue_callback_4CF + 2096
    14  CoreFoundation                      0x0000000182690d50 <redacted> + 12
    15  CoreFoundation                      0x000000018268ebb8 <redacted> + 1628
    16  CoreFoundation                      0x00000001825b8c50 CFRunLoopRunSpecific + 384
    17  GraphicsServices                    0x0000000183ea0088 GSEventRunModal + 180
    18  UIKit                               0x00000001878a2088 UIApplicationMain + 204
    19  ABC-iPhone                   0x0000000100737a88 main + 144
    20  libdyld.dylib                       0x00000001821568b8 <redacted> + 4
)
2016-05-31 17:13:16.991 SweetCouch-iPhone[5183:2764409] Invalid concurrent access to managed object calling 'release'; Stacktrace: (
    0   ABC-iPhone                   0x0000000100874ad0 ValidateConcurrency + 248
    1   ABC-iPhone                   0x0000000100874698 CustomSubclassRelease + 32
    2   ABC-iPhone                   0x00000001003734ec _TFC17ABC_iPhone16SWCPickedProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 124
    3   ABC-iPhone                   0x0000000100373548 _TToFC17ABC_iPhone16SWCPickedProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 76
    4   CoreData                            0x00000001845505cc <redacted> + 172
    5   CoreData                            0x000000018454f0dc <redacted> + 180
    6   CoreData                            0x00000001845e2490 <redacted> + 784
    7   CoreData                            0x00000001845e2a50 <redacted> + 348
    8   CoreData                            0x00000001845e4d8c <redacted> + 108
    9   libdispatch.dylib                   0x0000000101e41a3c _dispatch_client_callout + 16
    10  libdispatch.dylib                   0x0000000101e52040 _dispatch_barrier_sync_f_slow_invoke + 736
    11  libdispatch.dylib                   0x0000000101e41a3c _dispatch_client_callout + 16
    12  libdispatch.dylib                   0x0000000101e474e4 _dispatch_main_queue_callback_4CF + 2096
    13  CoreFoundation                      0x0000000182690d50 <redacted> + 12
    14  CoreFoundation                      0x000000018268ebb8 <redacted> + 1628
    15  CoreFoundation                      0x00000001825b8c50 CFRunLoopRunSpecific + 384
    16  GraphicsServices                    0x0000000183ea0088 GSEventRunModal + 180
    17  UIKit                               0x00000001878a2088 UIApplicationMain + 204
    18  ABC-iPhone                   0x0000000100737a88 main + 144
    19  libdyld.dylib                       0x00000001821568b8 <redacted> + 4
)
2016-05-31 17:13:16.995 SweetCouch-iPhone[5183:2764409] Invalid concurrent access to managed object calling 'release'; Stacktrace: (
    0   ABC-iPhone                   0x0000000100874ad0 ValidateConcurrency + 248
    1   ABC-iPhone                   0x0000000100874698 CustomSubclassRelease + 32
    2   ABC-iPhone                   0x00000001004c6710 _TFC17ABC_iPhone10SWCProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 136
    3   ABC-iPhone                   0x00000001003734c0 _TFC17ABC_iPhone16SWCPickedProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 80
    4   ABC-iPhone                   0x0000000100373548 _TToFC17ABC_iPhone16SWCPickedProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 76
    5   CoreData                            0x00000001845505cc <redacted> + 172
    6   CoreData                            0x000000018454f0dc <redacted> + 180
    7   CoreData                            0x00000001845e2490 <redacted> + 784
    8   CoreData                            0x00000001845e2a50 <redacted> + 348
    9   CoreData                            0x00000001845e4d8c <redacted> + 108
    10  libdispatch.dylib                   0x0000000101e41a3c _dispatch_client_callout + 16
    11  libdispatch.dylib                   0x0000000101e52040 _dispatch_barrier_sync_f_slow_invoke + 736
    12  libdispatch.dylib                   0x0000000101e41a3c _dispatch_client_callout + 16
    13  libdispatch.dylib                   0x0000000101e474e4 _dispatch_main_queue_callback_4CF + 2096
    14  CoreFoundation                      0x0000000182690d50 <redacted> + 12
    15  CoreFoundation                      0x000000018268ebb8 <redacted> + 1628
    16  CoreFoundation                      0x00000001825b8c50 CFRunLoopRunSpecific + 384
    17  GraphicsServices                    0x0000000183ea0088 GSEventRunModal + 180
    18  UIKit                               0x00000001878a2088 UIApplicationMain + 204
    19  ABC-iPhone                   0x0000000100737a88 main + 144
    20  libdyld.dylib                       0x00000001821568b8 <redacted> + 4
)
2016-05-31 17:13:16.998 SweetCouch-iPhone[5183:2764409] Invalid concurrent access to managed object calling 'release'; Stacktrace: (
    0   ABC-iPhone                   0x0000000100874ad0 ValidateConcurrency + 248
    1   ABC-iPhone                   0x0000000100874698 CustomSubclassRelease + 32
    2   ABC-iPhone                   0x00000001003734ec _TFC17ABC_iPhone16SWCPickedProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 124
    3   ABC-iPhone                   0x0000000100373548 _TToFC17ABC_iPhone16SWCPickedProductcfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 76
    4   CoreData                            0x00000001845505cc <redacted> + 172
    5   CoreData                            0x000000018454f0dc <redacted> + 180
    6   CoreData                            0x00000001845e2490 <redacted> + 784
    7   CoreData                            0x00000001845e2a50 <redacted> + 348
    8   CoreData                            0x00000001845e4d8c <redacted> + 108
    9   libdispatch.dylib                   0x0000000101e41a3c _dispatch_client_callout + 16
    10  libdispatch.dylib                   0x0000000101e52040 _dispatch_barrier_sync_f_slow_invoke + 736
    11  libdispatch.dylib                   0x0000000101e41a3c _dispatch_client_callout + 16
    12  libdispatch.dylib                   0x0000000101e474e4 _dispatch_main_queue_callback_4CF + 2096
    13  CoreFoundation                      0x0000000182690d50 <redacted> + 12
    14  CoreFoundation                      0x000000018268ebb8 <redacted> + 1628
    15  CoreFoundation                      0x00000001825b8c50 CFRunLoopRunSpecific + 384
    16  GraphicsServices                    0x0000000183ea0088 GSEventRunModal + 180
    17  UIKit                               0x00000001878a2088 UIApplicationMain + 204
    18  ABC-iPhone                   0x0000000100737a88 main + 144
    19  libdyld.dylib                       0x00000001821568b8 <redacted> + 4
)
.
.
.
So on

I'm using 4 different Managed Object Models and their 4 respective Persistent Store Coordinators.
There are 2 Managed Object Context for each coordinator, one context is for main thread, and other is for background lengthy operations.
I'm pretty sure i'm not accessing contexts on multiple threads, doing all operations within perform block of respective context.
I'm using swift 2.0
I'm not sure whats happening here, plz help.
Following is the code where i'm accessing data, and getting this warning

//Using this context for main thread    
internal lazy var managedObjectContext: NSManagedObjectContext? = {
        let coordinator = self.persistentStoreCoordinator
        if coordinator == nil {
            return nil
        }
        var managedObjectContext = NSManagedObjectContext(concurrencyType: NSManagedObjectContextConcurrencyType.MainQueueConcurrencyType)
        managedObjectContext.persistentStoreCoordinator = coordinator
        return managedObjectContext
        }()
//Using this context for background operations
    internal lazy var managedObjectContext_lenghtyThread: NSManagedObjectContext? = {
        if self.managedObjectContext == nil{return nil}
        var managedObjectContext_lenghtyThread = NSManagedObjectContext(concurrencyType: NSManagedObjectContextConcurrencyType.PrivateQueueConcurrencyType)
        managedObjectContext_lenghtyThread.parentContext = self.managedObjectContext
        return managedObjectContext_lenghtyThread
        }()

//Here i'm getting this warning
        let fetchRequest = NSFetchRequest(entityName: self.ENTITY_SWCPickedProduct)
        self.managedObjectContext_lenghtyThread?.performBlock({ () -> Void in
            let resultOject:AnyObject? = try?     
            self.managedObjectContext_lenghtyThread!.executeFetchRequest(fetchRequest)
            if resultOject is [SWCPickedProduct]
            {
            }
        })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant