ios - Crash report when user accesses the address book -


in app, crashlytics used gather crash reports users. here 1 crash report user. possibly depending on contacts informations of user. can not recreate crash, not know what's in his/her contacts. 1 has idea situation?

com.apple.root.default-priority crashed 0    corefoundation  cfstringcreatecopy + 13 1    appsupport  cpsqlitedatabasecreatewithpath + 36 2    appsupport  cpsqlitedatabasecreatewithpath + 36 3    appsupport  cprecordstoregetdatabase + 16 4    appsupport  _getreaderconnection + 10 5    appsupport  cprecordstoreprocessquerywithbindblock + 22 6    appsupport  cprecordstorecopyallinstancesofclasswherewithbindblock + 98 7    addressbook     abccopyarrayofallpeopleinsourcewithsortordering + 244 8    seeyoukee  phonenumberinputviewcontroller.m line 538-[phonenumberinputviewcontroller dofetchcontacts:] 9    addressbook     __37-[abtcc accessrequestwithcompletion:]_block_invoke_0 + 26 10   tcc     __tccaccessrequest_block_invoke_038 + 316 11 ...   libxpc.dylib    _xpc_connection_call_reply + 26 12   libdispatch.dylib   _dispatch_root_queue_drain + 278 13   libdispatch.dylib   _dispatch_worker_thread2 + 92 14   libsystem_c.dylib   _pthread_wqthread + 360 

the code 8 seeyoukee phonenumberinputviewcontroller.m line 538-[phonenumberinputviewcontroller dofetchcontacts:] is:

nsarray *contactsinaddressbook = cfbridgingrelease(abaddressbookcopyarrayofallpeopleinsourcewithsortordering(addressbook, nil, kabpersonsortbylastname)); 

edit 1

-(void)dofetchcontacts:(abaddressbookref)addressbook{ nsmutablearray *contactmutarr = [nsmutablearray array]; nsmutablestring *mstrofcontacts = [nsmutablestring string];  nsarray *contactsinaddressbook = cfbridgingrelease(abaddressbookcopyarrayofallpeopleinsourcewithsortordering(addressbook, nil, kabpersonsortbylastname));  if (abpersongetcompositenameformat() == kabpersoncompositenameformatlastnamefirst) {      (id aperson in contactsinaddressbook) {          abrecordref person = (__bridge abrecordref)(aperson);          abmultivalueref phonemultivalue = abrecordcopyvalue(person, kabpersonphoneproperty);         abmultivalueref emailmultivalue = abrecordcopyvalue(person, kabpersonemailproperty);         int countphone = 0;         int countemail = 0;         nsmutablearray *phonestrarr;         nsmutablearray *emailstrarr;          if (phonemultivalue != null) {             countphone = abmultivaluegetcount(phonemultivalue);         }          if (emailmultivalue != null) {             countemail = abmultivaluegetcount(emailmultivalue);         }          if (countemail>0) {             emailstrarr = [nsmutablearray array];             (int = 0; < countemail; i++) {                 cfstringref anemailcf = abmultivaluecopyvalueatindex(emailmultivalue, i);                 nsstring *anemail = (__bridge nsstring *)anemailcf;                 [emailstrarr addobject:anemail];                 if (anemailcf != null)cfrelease(anemailcf);             }         }          if (countphone > 0) {              phonestrarr = [nsmutablearray array];             (int = 0; < countphone; i++) {                 cfstringref anphonecf = abmultivaluecopyvalueatindex(phonemultivalue, i);                 nsstring *anphone = (__bridge nsstring *)anphonecf;                 nscharacterset *cs = [[nscharacterset charactersetwithcharactersinstring:@"0123456789"] invertedset];                 nsstring *anphonepurenumber = [[anphone componentsseparatedbycharactersinset:cs] componentsjoinedbystring:@""];                 [phonestrarr addobject:anphonepurenumber];                 if (anphonecf != null)cfrelease(anphonecf);             }          }         //                if (arrrefofemails != null)cfrelease(arrrefofemails);           cfstringref lastnamemultivaluecf = abrecordcopyvalue(person, kabpersonlastnameproperty);         cfstringref firstnmaemultivaluecf = abrecordcopyvalue(person, kabpersonfirstnameproperty);         cfstringref middlenmaemultivaluecf = abrecordcopyvalue(person, kabpersonmiddlenameproperty);         nsstring *lastnamemultivalue = (__bridge nsstring *)lastnamemultivaluecf;         nsstring *firstnmaemultivalue = (__bridge nsstring *)firstnmaemultivaluecf;         nsstring *middlenmaemultivalue = (__bridge nsstring *)middlenmaemultivaluecf;          nsstring *name = [nsstring stringwithformat:@"%@%@%@",(![lastnamemultivalue length])?@"":lastnamemultivalue, (![middlenmaemultivalue length])?@"":middlenmaemultivalue, (![firstnmaemultivalue length])?@"":firstnmaemultivalue];          if (lastnamemultivaluecf != null)cfrelease(lastnamemultivaluecf);         if (firstnmaemultivaluecf != null)cfrelease(firstnmaemultivaluecf);         if (middlenmaemultivaluecf != null)cfrelease(middlenmaemultivaluecf);         cfdataref anavatarcf = abpersoncopyimagedatawithformat(person, kabpersonimageformatthumbnail);          nsdata *anavatardata = (__bridge nsdata *)anavatarcf;         uiimage *anavatar = [uiimage imagewithdata:anavatardata];          if (anavatarcf != null)cfrelease(anavatarcf);          nsdictionary *apersondict = [nsdictionary dictionarywithobjectsandkeys:name, @"name", [phonestrarr componentsjoinedbystring:@"; "], @"phonenumber", [emailstrarr componentsjoinedbystring:@"; "], @"email", anavatar, @"avatar", nil];         [contactmutarr addobject:apersondict];          nslog(@"------phonestrarr :%@",phonestrarr);         nsstring *enphonenumber = @"";         if (phonestrarr) {             enphonenumber = [encryptwithmd5 encryptwithmd5: [phonestrarr componentsjoinedbystring:@"; "]];         }         [mstrofcontacts appendstring:enphonenumber];         [mstrofcontacts appendstring:@", "];         if (phonemultivalue != null)cfrelease(phonemultivalue);         if (emailmultivalue != null)cfrelease(emailmultivalue);      }  }else{      (id aperson in contactsinaddressbook) {         abrecordref person = (__bridge abrecordref)(aperson);         abmultivalueref phonemultivalue = abrecordcopyvalue(person, kabpersonphoneproperty);         abmultivalueref emailmultivalue = abrecordcopyvalue(person, kabpersonemailproperty);         int countemail = 0;         nsmutablearray *emailstrarr;         nsmutablearray *phonestrarr;          if (emailmultivalue != null) {             countemail = abmultivaluegetcount(emailmultivalue);         }          if (countemail>0) {             emailstrarr = [nsmutablearray array];             (int = 0; < countemail; i++) {                 cfstringref anemailcf = abmultivaluecopyvalueatindex(emailmultivalue, i);                 nsstring *anemail = (__bridge nsstring *)anemailcf;                 [emailstrarr addobject:anemail];                 if (anemailcf != null)cfrelease(anemailcf);             }         }          int count = abmultivaluegetcount(phonemultivalue);          if (count > 0) {             phonestrarr = [nsmutablearray array];             (int = 0; < count; i++) {                 cfstringref anphonecf = abmultivaluecopyvalueatindex(phonemultivalue, i);                 nsstring *anphone = (__bridge nsstring *)anphonecf;                 nscharacterset *cs = [[nscharacterset charactersetwithcharactersinstring:@"0123456789"] invertedset];                 nsstring *anphonepurenumber = [[anphone componentsseparatedbycharactersinset:cs] componentsjoinedbystring:@""];                 [phonestrarr addobject:anphonepurenumber];                 if (anphonecf != null)cfrelease(anphonecf);             }         }          cfstringref lastnamemultivaluecf = abrecordcopyvalue(person, kabpersonlastnameproperty);         cfstringref firstnmaemultivaluecf = abrecordcopyvalue(person, kabpersonfirstnameproperty);         cfstringref middlenmaemultivaluecf = abrecordcopyvalue(person, kabpersonmiddlenameproperty);         nsstring *lastnamemultivalue = (__bridge nsstring *)lastnamemultivaluecf;         nsstring *firstnmaemultivalue = (__bridge nsstring *)firstnmaemultivaluecf;         nsstring *middlenmaemultivalue = (__bridge nsstring *)middlenmaemultivaluecf;          nsstring *name = [nsstring stringwithformat:@"%@%@%@", (![firstnmaemultivalue length])?@"":firstnmaemultivalue, (![middlenmaemultivalue length])?@"":middlenmaemultivalue,(![lastnamemultivalue length])?@"":lastnamemultivalue];          if (lastnamemultivaluecf != null)cfrelease(lastnamemultivaluecf);         if (firstnmaemultivaluecf != null)cfrelease(firstnmaemultivaluecf);         if (middlenmaemultivaluecf != null)cfrelease(middlenmaemultivaluecf);          cfdataref anavatarcf = abpersoncopyimagedatawithformat(person, kabpersonimageformatthumbnail);          nsdata *anavatardata = (__bridge nsdata *)anavatarcf;         uiimage *anavatar = [uiimage imagewithdata:anavatardata];          if (anavatarcf != null)cfrelease(anavatarcf);          nsdictionary *apersondict = [nsdictionary dictionarywithobjectsandkeys:name, @"name", [phonestrarr componentsjoinedbystring:@"; "], @"phonenumber",  [emailstrarr componentsjoinedbystring:@"; "], @"email", anavatar, @"avatar", nil];         [contactmutarr addobject:apersondict];          nsstring *enphonenumber = [encryptwithmd5 encryptwithmd5: [phonestrarr componentsjoinedbystring:@"; "]];         [mstrofcontacts appendstring:enphonenumber];         [mstrofcontacts appendstring:@", "];          if (phonemultivalue != null)cfrelease(phonemultivalue);         if (emailmultivalue != null)cfrelease(emailmultivalue);      }   } self.contactarr = [[nsarray alloc] initwitharray: contactmutarr]; strofcontacts = [nsstring stringwithstring:mstrofcontacts]; } 

edit 2

-(void)beginfetchcontacts{ // request authorization address book abaddressbookref addressbookref = null;  if (abaddressbookrequestaccesswithcompletion) {     cferrorref *aerror=nil;     addressbookref = abaddressbookcreatewithoptions(null, aerror);      if (abaddressbookgetauthorizationstatus() == kabauthorizationstatusnotdetermined) {         abaddressbookrequestaccesswithcompletion(addressbookref, ^(bool granted, cferrorref error) {             // first time access has been granted, add contact             if (granted) {                 [self dofetchcontacts:addressbookref];             }else{                 //                [self alertactionswitchonthecontactsaccess];                 [self buttoncancelpressed:nil];             }         });     }     else if (abaddressbookgetauthorizationstatus() == kabauthorizationstatusauthorized) {         // user has given access, add contact         [self dofetchcontacts:addressbookref];     } }else{     addressbookref = abaddressbookcreate();     [self dofetchcontacts:addressbookref]; }  if (addressbookref != null)cfrelease(addressbookref); } 

could you're calling abaddressbookcreatewithoptions() and/or abaddressbookrequestaccesswithcompletion() on different thread you're calling abaddressbookcopyarrayofallpeopleinsourcewithsortordering()?

please note following apple's api documentation:

the completion handler called on arbitrary queue. if app uses address book throughout app, responsible ensuring usage of address book dispatched single queue ensure correct thread-safe operation.

source: http://developer.apple.com/library/ios/#documentation/addressbook/reference/abaddressbookref_iphoneos/reference/reference.html

alternatively, check make sure you're not prematurely releasing abaddressbookref got abaddressbookcreatewithoptions(). remember abaddressbookrequestaccesswithcompletion() asynchronous.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -