0

A subset of my app users are reporting a crash. When I symbolicated one of their crash logs, I found the offending code to be the label read.

Here is the output from the crash log:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000
Crashed Thread:  0
Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   CoreFoundation                  0x33e5004e 0x33e4d000 + 12366
1   CoreFoundation                  0x33e58cfc 0x33e4d000 + 48380
2   Mail my meeting                 0x00002a9c -[Mail_my_meetingAppDelegate initPeople] Mail_my_meetingAppDelegate.m:136)
3   Mail my meeting                 0x0000287a -[Mail_my_meetingAppDelegate application:didFinishLaunchingWithOptions:] (Mail_my_meetingAppDelegate.m:74)

And here is the the code, with line 136 being the last line:

NSString* finalName=[NSString stringWithFormat:@"%@%@%@",firstName,middleName,lastName];
NSString *phoneNumber = nil;
ABMultiValueRef phoneNumbers1 = ABRecordCopyValue(person,kABPersonPhoneProperty);
if (ABMultiValueGetCount(phoneNumbers1) > 0) {
    CFIndex j;
    for (j=0; j < ABMultiValueGetCount(phoneNumbers1); j++) {
        CFStringRef label = ABMultiValueCopyLabelAtIndex(phoneNumbers1, j);

I can't understand how this last line could cause a crash, because I validate that it is less than the count, and it starts at zero.

This is driving me a bit crazy, so any ideas at all are welcome!

dougDNA
  • 11
  • 1
  • Did you already released the address book reference? If yes, take a look http://stackoverflow.com/questions/8630738/cannot-read-kabpersonphoneproperty, I had a similar problem a bit ago. – Manlio Apr 26 '12 at 11:47

2 Answers2

0

I had similar problem.

Who is calling the crashing method?

Check if the method who is calling and the method that crashes are running in the same thread/queue. Or at least all your AB related methods run in the same queue/thread.

If yes check that when you create your first instance of all the AB variables they are created in the same thread or queue.

Basically you need to access the AB functions always in the same queue or thread!

João Nunes
  • 3,751
  • 31
  • 32
0

It could be a Corrupted Address Book, I have seen that sometimes.

But In most cases it is due to accessing the AB database in different Queues or Threads.

João Nunes
  • 3,751
  • 31
  • 32