ipv6 app rejection caused by cloudkit framework crash

My app was rejected by app store review. The reviewer send ove several crash reports.


I symbolicate all of them and and this is what I always get for the crashing thread. And it always go back to CKDatabase(ConvenienceMethods)


Thread 5 name:  Dispatch queue: com.apple.cloudkit.operation.callback
    Thread 5 Crashed:
    0   MyApp                     0x0000000100093630 0x10003c000 + 357936
    1   CloudKit                       0x000000018a329650 __70-[CKDatabase(ConvenienceMethods) fetchRecordWithID:completionHandler:]_block_invoke + 324
    2   CloudKit                       0x000000018a33e220 -[CKFetchRecordsOperation _finishOnCallbackQueueWithError:] + 556
    3   CloudKit                       0x000000018a313a30 -[CKOperation _finishInternalOnCallbackQueueWithError:] + 516
    4   CloudKit                       0x000000018a313818 -[CKOperation _handleCompletionCallback:] + 120
    5   CloudKit                       0x000000018a3160ec __ck_dispatch_async_block_invoke + 36
    6   libdispatch.dylib             0x00000001813114bc _dispatch_call_block_and_release + 24
    7   libdispatch.dylib             0x000000018131147c _dispatch_client_callout + 16
    8   libdispatch.dylib             0x000000018131d4c0 _dispatch_queue_drain + 864
    9   libdispatch.dylib             0x0000000181314f80 _dispatch_queue_invoke + 464
    10  libdispatch.dylib             0x000000018131f390 _dispatch_root_queue_drain + 728
    11  libdispatch.dylib             0x000000018131f0b0 _dispatch_worker_thread3 + 112
    12  libsystem_pthread.dylib       0x0000000181529470 _pthread_wqthread + 1092
    13  libsystem_pthread.dylib       0x0000000181529020 start_wqthread + 4


When I try to symbolicate the '0x0000000100093630 0x10003c000 + 357936'. I get this, which is not very helpful


    0x0000000100093630
    0x10003c000
    +
    0x00357936 (in MyApp)


Everytime I use fetchRecordWithID:completionHandler I am making an assynchronous call. Also, I am using these methods in a pretty standard way. The only framework added to the app is CloudKit. I am following all requirement posted here Supporting IPv6 DNS64/NAT64 Networks


From all what I can see it is the CloudKit framework what is causing all the crashes. But unfortunatelly I have not idea why as there is nothing obvious on my code.


Any idea what am I doing wrong here? Or really seems to be an IPv6 compatibility bug on CloudKit framework?!


This is the crash report I got from Apple


  Version:             3 (1.0)
    Code Type:           ARM-64 (Native)
    Parent Process:      launchd [1]

    Date/Time:           2016-07-21 17:01:01.01 -0700
    Launch Time:         2016-07-21 17:01:00.00 -0700
    OS Version:          iOS 9.3.2 (13F69)
    Report Version:      105

    Exception Type:  EXC_BREAKPOINT (SIGTRAP)
    Exception Codes: 0x0000000000000001, 0x0000000100093630
    Triggered by Thread:  5

    Thread 5 name:  Dispatch queue: com.apple.cloudkit.operation.callback
    Thread 5 Crashed:
    0   MyApp                         0x0000000100093630 0x10003c000 + 357936
    1   CloudKit                       0x000000018a329650 0x18a2d0000 + 366160
    2   CloudKit                       0x000000018a33e220 0x18a2d0000 + 451104
    3   CloudKit                       0x000000018a313a30 0x18a2d0000 + 277040
    4   CloudKit                       0x000000018a313818 0x18a2d0000 + 276504
    5   CloudKit                       0x000000018a3160ec 0x18a2d0000 + 286956
    6   libdispatch.dylib             0x00000001813114bc 0x181310000 + 5308
    7   libdispatch.dylib             0x000000018131147c 0x181310000 + 5244
    8   libdispatch.dylib             0x000000018131d4c0 0x181310000 + 54464
    9   libdispatch.dylib             0x0000000181314f80 0x181310000 + 20352
    10  libdispatch.dylib             0x000000018131f390 0x181310000 + 62352
    11  libdispatch.dylib             0x000000018131f0b0 0x181310000 + 61616
    12  libsystem_pthread.dylib       0x0000000181529470 0x181528000 + 5232
    13  libsystem_pthread.dylib       0x0000000181529020 0x181528000 + 4128

    Activity ID:             0x0000000000005793
    Activity Name:           !client/fetch-records
    Activity Image Path:     /System/Library/Frameworks/CloudKit.framework/CloudKit
    Activity Image UUID:     5A0898B0-056F-3AA8-BB9A-6F5E84185C9A
    Activity Offset:         0x0006e328
    Activity Running Time:   0.876357 sec

    Thread 5 crashed with ARM Thread State (64-bit):
        x0: 0x0000000000000000   x1: 0x0000000100318be0   x2: 0x000000013e767950   x3: 0x000000013e767950
        x4: 0x000000000000000a   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x000000016e246948
        x8: 0x0000000000000001   x9: 0x000000016e2470e0  x10: 0x0000000000000000  x11: 0x000000170000001f
       x12: 0x000000013e599b30  x13: 0x0000000100365be8  x14: 0x0000000000010201  x15: 0x02325ecfaa4f70c7
       x16: 0x0000000180f45ef0  x17: 0x000000010032fe98  x18: 0x0000000000000000  x19: 0x000000013e75d250
       x20: 0x0000000000000000  x21: 0x00000001000d8000  x22: 0x000000013e79bb90  x23: 0x000000013e7a3e81
       x24: 0x000000000000007c  x25: 0x4000000000000021  x26: 0x000000013e7a3e70  x27: 0x000000016e246b28
       x28: 0x000000013e767950  fp: 0x000000016e246be0   lr: 0x00000001000934bc
        sp: 0x000000016e2469f0   pc: 0x0000000100093630 cpsr: 0x60000000

Hi,


it seems your completion handler in [CKDatabase(ConvenienceMethods) fetchRecordWithID:completionHandler:]

crashes somehow.


I would check all occurences of that method and take a deeper look at the completion handler.


BTW. Did the app store reviewer send just crash reports or also a description how to reproduce these crashes? If not I would ask, if the crash is somehow reproducible.


Dirk

Hi Dirk,


They only mentioned the app was crashing always when launched. On my enviroment the app hardly crashes and could not reproduce the crash at all. The said it could be IPv6 incompatibility, but I could not find anything to justify that. The only framework added to the app is CloudKit. By the looks of it could be that cloudkit is causing the IPv6 crash... but I can't test it of fix CloudKit. They must look onto it.


Here is an example of how I hande CloudKit queries all over the app. These methods are always called with 'dispatch_async(dispatch_get_main_queue()) {'


func cloudKitCheckIfUserIsOniCloud (result: (error: NSError?, succeed: Bool, takeUserToiCloud: Bool, bannedUser: Bool?, bannedUserMessage: String?) -> Void){
  
    let classPublicUsers = ClassPublicUsers()
    var bannedUser = false
    var bannedUserMessage = ""
  
    let container = CKContainer.defaultContainer()
    container.fetchUserRecordIDWithCompletionHandler{(fetchedRecordId: CKRecordID?, error: NSError?) in
        if error != nil
        {
            print("-> cloudKitCheckIfUserIsOniCloud - error fetching ID - other error \(error!.description)")
            result(error: error, succeed: false, takeUserToiCloud: true, bannedUser:  nil, bannedUserMessage:  nil)
        }
        else
        {
            if let recordId = fetchedRecordId
            {
                let publicDatabase = CKContainer.defaultContainer().publicCloudDatabase
                publicDatabase.fetchRecordWithID(recordId, completionHandler: { (fetchedRecord: CKRecord?, error: NSError?) in
                    if error != nil
                    {
                        /
                        print("-> cloudKitCheckIfUserIsOniCloud - error fetching user record - Error \(error)")
                        result(error: error, succeed: false, takeUserToiCloud: false, bannedUser:  nil, bannedUserMessage:  nil)
                    }
                    else
                    {
                        if let record = fetchedRecord
                        {
                            if record.recordType == CKRecordTypeUserRecord
                            {
                                /
                                print("-> cloudKitCheckIfUserIsOniCloud - fetching user record - valid record found - \(record.recordID.recordName))")
                                let useriCloudID = record.recordID.recordName
                                classPublicUsers.set_useriCloudID((useriCloudID))
                                /
                                bannedUser = record.objectForKey("bannedUser") as! Bool
                                bannedUserMessage = record.objectForKey("bannedUserMessage") as! String
                                result(error: nil, succeed: true, takeUserToiCloud: false, bannedUser: bannedUser, bannedUserMessage: bannedUserMessage)
                            }
                            else
                            {
                                /
                                print("-> cloudKitCheckIfUserIsOniCloud - fetching user record - The record that came back is not a user record")
                                result(error: nil, succeed: false, takeUserToiCloud: false, bannedUser:  nil, bannedUserMessage: nil)
                            }
                        }
                        else
                        {
                            /
                            print("-> cloudKitCheckIfUserIsOniCloud - fetching user record - fetch record nil")
                            result(error: nil, succeed: false, takeUserToiCloud: false, bannedUser:  nil, bannedUserMessage: nil)
                        }
                    }
                })
            }
            else
            {
                print("-> cloudKitCheckIfUserIsOniCloud - error fetching ID - id nil")
                result(error: nil, succeed: false, takeUserToiCloud: false, bannedUser:  nil, bannedUserMessage: nil)
            }
        }
    }
}

Maybe it's a matter of on what thread you're completion handler of

publicDatabase.fetchRecordWithID

is called. Altough you call the method on the main thread the completion handler is likely to be called on a different thread. This may lead to a problem if your "result" block does UI related stuff.


Dirk

Looks to me that the most important step in figuring this out is fixing the problem with not being able to symbolicate an address inside your app's code.

(I don't know why that's happening, just that it seems like the primary blocker.)

If you're doing any UI adjustments in the completion handler, it needs to be done on the main thread. I don't know if that's your problem.

ipv6 app rejection caused by cloudkit framework crash
 
 
Q