_PFFaultHandlerLookupRow Crash #301

Closed
opened 2025-12-29 18:25:28 +01:00 by adam · 4 comments
Owner

Originally created by @seanliu1 on GitHub (Jan 9, 2020).

We are experiencing this crash, would love your help to figure out what's going on.

Crashed: Updater
0  libobjc.A.dylib                0x182fb0fb0 objc_msgSend + 16
1  CoreData                       0x187d10dd8 _PFFaultHandlerLookupRow + 1064
2  CoreData                       0x187d12ac4 _PF_FulfillDeferredFault + 248
3  CoreData                       0x187d26d38 _pvfk_header + 120
4  CoreData                       0x187d26b78 _sharedIMPL_pvfk_core_q + 32
5  CoreData                       0x187d26e40 __generateAccessor_block_invoke + 28

Here is what we are doing

dataStack.perform(asynchronous: { (transaction) in  
  let objects = try transaction.fetchAll()
  backgroundQueue.async {
    URLSession.shared.dataTask(){
      dataStack.perform(asynchronous: {(transaction) in
        let item =  try transaction.fetchOne()
         // update item fetched object 
        }, completion: { _ in
     })
    }
   }
}, completion: { (result) in {

})

Thanks for your help.

Originally created by @seanliu1 on GitHub (Jan 9, 2020). We are experiencing this crash, would love your help to figure out what's going on. ``` Crashed: Updater 0 libobjc.A.dylib 0x182fb0fb0 objc_msgSend + 16 1 CoreData 0x187d10dd8 _PFFaultHandlerLookupRow + 1064 2 CoreData 0x187d12ac4 _PF_FulfillDeferredFault + 248 3 CoreData 0x187d26d38 _pvfk_header + 120 4 CoreData 0x187d26b78 _sharedIMPL_pvfk_core_q + 32 5 CoreData 0x187d26e40 __generateAccessor_block_invoke + 28 ``` Here is what we are doing ``` dataStack.perform(asynchronous: { (transaction) in let objects = try transaction.fetchAll() backgroundQueue.async { URLSession.shared.dataTask(){ dataStack.perform(asynchronous: {(transaction) in let item = try transaction.fetchOne() // update item fetched object }, completion: { _ in }) } } }, completion: { (result) in { }) ``` Thanks for your help.
adam added the question label 2025-12-29 18:25:28 +01:00
adam closed this issue 2025-12-29 18:25:28 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Jan 9, 2020):

Which line are you getting the exception from? Try to add an Exception Breakpoint and let me know which line it stops

@JohnEstropia commented on GitHub (Jan 9, 2020): Which line are you getting the exception from? Try to add an Exception Breakpoint and let me know which line it stops
Author
Owner

@seanliu1 commented on GitHub (Jan 9, 2020):

At least xcode stops/ crashes at the line when we use fetched objects to construct network request.

let objects = try transaction.fetchAll()
  backgroundQueue.async {
  // construct url request (crashed here)
    URLSession.shared.dataTask(){

Should we access fetched object in different thread?

@seanliu1 commented on GitHub (Jan 9, 2020): At least xcode stops/ crashes at the line when we use fetched objects to construct network request. ``` let objects = try transaction.fetchAll() backgroundQueue.async { // construct url request (crashed here) URLSession.shared.dataTask(){ ``` Should we access fetched object in different thread?
Author
Owner

@JohnEstropia commented on GitHub (Jan 10, 2020):

I'm guessing you omitted some code here, but you can't use transaction objects outside the transaction closure. You can't dispatch them out into another queue.

My suggestion is to use the object values immediately to create the request, and pass the request to the background instead.

dataStack.perform(
    asynchronous: { (transaction) -> URLRequest in  
        let objects = try transaction.fetchAll()
        let request: URLRequest = // ...
        return request
    }, 
    completion: { (result) in {
        guard case .success(let request) = result else {
            return
        }
        backgroundQueue.async {
            URLSession.shared.dataTask(request) { response in
                // ...
                dataStack.perform(
                    asynchronous: { (transaction) in
                        let item =  try transaction.fetchOne()
                         // update item fetched object 
                    }, 
                    completion: { _ in }
                )
            }
        }
    }
)

Another way is to use

@JohnEstropia commented on GitHub (Jan 10, 2020): I'm guessing you omitted some code here, but you can't use transaction objects outside the transaction closure. You can't dispatch them out into another queue. My suggestion is to use the object values immediately to create the request, and pass the request to the background instead. ```swift dataStack.perform( asynchronous: { (transaction) -> URLRequest in let objects = try transaction.fetchAll() let request: URLRequest = // ... return request }, completion: { (result) in { guard case .success(let request) = result else { return } backgroundQueue.async { URLSession.shared.dataTask(request) { response in // ... dataStack.perform( asynchronous: { (transaction) in let item = try transaction.fetchOne() // update item fetched object }, completion: { _ in } ) } } } ) ``` Another way is to use
Author
Owner

@seanliu1 commented on GitHub (Jan 19, 2020):

thanks

@seanliu1 commented on GitHub (Jan 19, 2020): thanks
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#301