Exception Codes: KERN_INVALID_ADDRESS at 0x0000003d

0

I am using address book framework for my application and I have got crashes on that code. That code is shown below

+(NSMutableArray *)getcontactdetails
{
    [self current_function_name:@"Inside getcontactdetails"];
    NSMutableArray *list = [[NSMutableArray alloc] init];
    ABAddressBookRef addressBook;
    CFArrayRef allSources;
    addressBook = ABAddressBookCreate();
    ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
    allSources = ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook,    source, kABPersonFirstNameProperty);
    CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);

    if(nPeople != 0){
        for (CFIndex i = 0; i < nPeople; i++)
        {
            //common field
            NSString *basic_email =[[NSString alloc] init] ;
            NSString *basic_mobile =[[NSString alloc] init] ;
            //personal filed
            NSString *Home_email =[[NSString alloc] init] ;
            NSString*home_mobile =[[NSString alloc] init] ;
            NSString*home_address =[[NSString alloc] init];
            //business filed
            NSString *work_email =[[NSString alloc] init] ;
            NSString*work_mobile =[[NSString alloc] init] ;
            NSString *work_address =[[NSString alloc] init] ;

            contact_details *phone_book_data=[[contact_details alloc] init];
            ABRecordRef aSource = CFArrayGetValueAtIndex(allSources,i);

            // Fetch all groups included in the current source
            NSString *first_name = (NSString*)ABRecordCopyValue(aSource,   kABPersonFirstNameProperty);            
            if (![first_name isEqualToString:@"(null)"]){
                phone_book_data.FirstName=[NSString stringWithFormat:@"%@",first_name];
            }
            NSLog(@"last_name:-%@",first_name);

            NSString *last_name=(NSString*)ABRecordCopyValue(aSource, kABPersonLastNameProperty);
            if ([last_name isEqualToString:@"(null)"] || last_name == nil || last_name.length == 0) {
                phone_book_data.LastName=[NSString stringWithFormat:@""];
            }
            else{
                phone_book_data.LastName=[NSString stringWithFormat:@"%@",last_name];
            }
            NSLog(@"last_name:-%@",last_name);

            NSString *company_name=(NSString*)ABRecordCopyValue(aSource, kABPersonOrganizationProperty);
            NSLog(@"companyname:-%@",company_name);

            NSString *job_title=(NSString*)ABRecordCopyValue(aSource, kABPersonJobTitleProperty);
            NSLog(@"jobtitle:-%@",job_title);

            ABMultiValueRef address =(NSString*)ABRecordCopyValue(aSource, kABPersonAddressProperty);
            NSString* addLabel;
            for(CFIndex i = 0; i < ABMultiValueGetCount(address); i++) {
                addLabel=(NSString*)ABMultiValueCopyLabelAtIndex(address, i);
                if ([addLabel isEqualToString:(NSString*)kABWorkLabel])
                {
                    work_address=@"exist";
                }
                if ([addLabel isEqualToString:(NSString*)kABHomeLabel])
                {
                    home_address=@"exist";
                }
           }
           NSLog(@"work_address:-%@",work_address);
           NSLog(@"home_address:-%@",home_address);

        ABMultiValueRef phones =(NSString*)ABRecordCopyValue(aSource, kABPersonPhoneProperty);
        NSString* mobileLabel;
        for(CFIndex i = 0; i < ABMultiValueGetCount(phones); i++) {
            mobileLabel = (NSString*)ABMultiValueCopyLabelAtIndex(phones, i);

            if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMobileLabel])
            {
                home_mobile = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i) retain];
            }
            if ([mobileLabel isEqualToString:(NSString*)kABPersonPhoneIPhoneLabel])
            {
                basic_mobile = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i)retain];
            }
            if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMainLabel])
            {
                work_mobile = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i)retain];

            }
        }

        NSLog(@"home_mobile:-%@",home_mobile);
        NSLog(@"basic_mobile:-%@",basic_mobile);
        NSLog(@"work_mobile:-%@",work_mobile);

        ABMultiValueRef email = ABRecordCopyValue(aSource, kABPersonEmailProperty);
        NSString* email_lbl;
        for(CFIndex i = 0; i < ABMultiValueGetCount(email); i++) {
            email_lbl = (NSString*)ABMultiValueCopyLabelAtIndex(email, i);

            if([email_lbl isEqualToString:(NSString *)kABHomeLabel])
            {
                Home_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
            }
            if([email_lbl isEqualToString:(NSString *)kABWorkLabel])
            {
                work_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
            }
            if([email_lbl isEqualToString:(NSString *)kABOtherLabel]){
                basic_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
            }

        }

        NSLog(@"Home_email:-%@",Home_email);
        NSLog(@"work_email:-%@",work_email);
        NSLog(@"basic_email:-%@",basic_email);

        if ([company_name isEqualToString:@""] || [company_name isEqualToString:@"(null)"] || company_name.length == 0) {
            if ([job_title isEqualToString:@""] || [job_title isEqualToString:@"(null)"] || job_title.length == 0) {
                if ([work_address isEqualToString:@""] || [work_address isEqualToString:@"(null)"] || work_address.length == 0) {
                    if ([work_mobile isEqualToString:@""] || [work_mobile isEqualToString:@"(null)"] || work_mobile.length == 0) {
                        if ([work_email isEqualToString:@""] || [work_email isEqualToString:@"(null)"] || work_email.length == 0) {
                            phone_book_data.Type=[NSString stringWithFormat:@"personal"];
                        }
                        else{
                            phone_book_data.Type=[NSString stringWithFormat:@"business"];
                        }
                    }
                    else{
                        phone_book_data.Type=[NSString stringWithFormat:@"business"];
                    }
                }
                else
                {
                    phone_book_data.Type=[NSString stringWithFormat:@"business"];
                }
            }
            else{
                phone_book_data.Type=[NSString stringWithFormat:@"business"];
            }
        }
        else{
            phone_book_data.Type=[NSString stringWithFormat:@"business"];
        }


        if ([phone_book_data.Type isEqualToString:@"business"])
        {

            if ([work_mobile isEqualToString:@"(null)"] ||[work_mobile isEqualToString:@""] || work_mobile == nil || work_mobile.length == 0) {
                if ([basic_mobile isEqualToString:@"(null)"] || basic_mobile == nil || basic_mobile.length == 0) {
                    phone_book_data.MobileNumber = @"";
                }
                else{
                    phone_book_data.MobileNumber=[NSString stringWithFormat:@"%@",basic_mobile];
                }

            }
            else{
                phone_book_data.MobileNumber=[NSString stringWithFormat:@"%@",work_mobile];
            }

            if ([work_email isEqualToString:@"(null)"] || work_email == nil || work_email.length == 0)
            {
                if ([basic_email isEqualToString:@"(null)"] || basic_email == nil || basic_email.length == 0) {
                    phone_book_data.emailaddress=@"";
                }
                else{
                    if ([basic_email rangeOfString:@"gmail"].location != NSNotFound || [basic_email rangeOfString:@"yahoo"].location != NSNotFound || [basic_email rangeOfString:@"hotmail"].location != NSNotFound ||[basic_email rangeOfString:@"aol"].location != NSNotFound) {
                        phone_book_data.emailaddress=basic_email;
                    }
                    else{
                        phone_book_data.emailaddress=@"";
                    }
                }
            }
            else{
                if ([work_email rangeOfString:@"gmail"].location == NSNotFound || [work_email rangeOfString:@"yahoo"].location == NSNotFound || [work_email rangeOfString:@"hotmail"].location == NSNotFound ||[work_email rangeOfString:@"aol"].location == NSNotFound) {
                    phone_book_data.emailaddress=@"";
                }
                else{
                    phone_book_data.emailaddress=work_email;

                }
            }
        }

        else{
            if ([home_mobile isEqualToString:@"(null)"] || home_mobile == nil || home_mobile.length == 0) {
                if (![basic_mobile isEqualToString:@"(null)"] || basic_mobile != nil || basic_mobile.length != 0) {
                    phone_book_data.MobileNumber=[NSString stringWithFormat:@"%@",basic_mobile];
                }
                else{
                    phone_book_data.MobileNumber = @"";
                }
            }
            else{
                phone_book_data.MobileNumber=[NSString stringWithFormat:@"%@",home_mobile];
            }
            if ([Home_email isEqualToString:@"(null)"] || Home_email == nil || Home_email.length == 0)
            {
                if ([basic_email isEqualToString:@"(null)"] || basic_email == nil || basic_email.length == 0) {
                    phone_book_data.emailaddress=@"";
                }
                else{
                    phone_book_data.emailaddress=basic_email;
                }
            }
            else{
                phone_book_data.emailaddress=Home_email;
            }


        }

        if(ABPersonHasImageData(aSource)){
            phone_book_data.contact_image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(aSource)];
        }else{
            phone_book_data.contact_image = [UIImage imageNamed:@"blank_image.png"];
        }

        phone_book_data.isselected=TRUE;
        [list addObject:phone_book_data];
        [phone_book_data release];
        phone_book_data=nil;


    }
}
    CFRelease(allSources);

    [self current_function_name:@"Finished getcontactdetails"];

    return list;
}

Now i got this error in crash reports.

ncident Identifier: C28DCEAD-5DCD-469B-9349-46F59A92B25E

CrashReporter Key: e1b5c8f591e28608a399ebe58d339df84ab3ae52

Hardware Model: iPhone3,1

Process: intooch [163]

Path: /var/mobile/Applications/CB8405B7-8B2A-4226-9134-D99AC5474776/intooch.app/intooch

Identifier: intooch

Version: ??? (???)

Code Type: ARM (Native)

Parent Process: launchd [1]

Date/Time: 2012-09-09 22:45:57.023 -0700

OS Version: iPhone OS 5.1.1 (9B208)

Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)

Exception Codes: KERN_INVALID_ADDRESS at 0x0000003d

Crashed Thread: 4

Thread 0 name: Dispatch queue: com.apple.main-thread

Thread 0:

0 libsystem_kernel.dylib 0x365ef004 0x365ee000 + 4100

1 libsystem_kernel.dylib 0x365ef1fa 0x365ee000 + 4602

2 CoreFoundation 0x369bd3ec 0x36930000 + 578540

3 CoreFoundation 0x369bc0ea 0x36930000 + 573674

4 CoreFoundation 0x3693f49e 0x36930000 + 62622

5 CoreFoundation 0x3693f366 0x36930000 + 62310

6 GraphicsServices 0x34b06432 0x34b02000 + 17458

7 UIKit 0x34be8cce 0x34bb7000 + 203982

8 intooch 0x00049648 0x45000 + 17992

9 intooch 0x00047138 0x45000 + 8504

Thread 1 name: Dispatch queue: com.apple.libdispatch-manager

Thread 1:

0 libsystem_kernel.dylib 0x365ef3a8 0x365ee000 + 5032

1 libdispatch.dylib 0x3741cea4 0x37410000 + 52900

2 libdispatch.dylib 0x3741cbc2 0x37410000 + 52162

Thread 2 name: WebThread

Thread 2:

0 libsystem_kernel.dylib 0x365ef004 0x365ee000 + 4100

1 libsystem_kernel.dylib 0x365ef1fa 0x365ee000 + 4602

2 CoreFoundation 0x369bd3ec 0x36930000 + 578540

3 CoreFoundation 0x369bc124 0x36930000 + 573732

4 CoreFoundation 0x3693f49e 0x36930000 + 62622

5 CoreFoundation 0x3693f366 0x36930000 + 62310

6 WebCore 0x31932c9c 0x31889000 + 695452

7 libsystem_c.dylib 0x32f3772e 0x32f29000 + 59182

8 libsystem_c.dylib 0x32f375e8 0x32f29000 + 58856

Thread 3:

0 libsystem_kernel.dylib 0x365ffcd4 0x365ee000 + 72916

1 libsystem_c.dylib 0x32f31f36 0x32f29000 + 36662

2 libsystem_c.dylib 0x32f31cc8 0x32f29000 + 36040

Thread 4 Crashed:

0 AppSupport 0x34937e8a 0x3492e000 + 40586

1 AppSupport 0x3493806e 0x3492e000 + 41070

2 AddressBook 0x315b8edc 0x315a7000 + 73436

3 intooch 0x00058618 0x45000 + 79384

4 intooch 0x0004a0b6 0x45000 + 20662

5 Foundation 0x32591a7a 0x32581000 + 68218

6 Foundation 0x3262558a 0x32581000 + 673162

7 libsystem_c.dylib 0x32f3772e 0x32f29000 + 59182

8 libsystem_c.dylib 0x32f375e8 0x32f29000 + 58856

Thread 5:

0 libsystem_kernel.dylib 0x365ffcd4 0x365ee000 + 72916

1 libsystem_c.dylib 0x32f31f36 0x32f29000 + 36662

2 libsystem_c.dylib 0x32f31cc8 0x32f29000 + 36040

Thread 6 name: com.apple.NSURLConnectionLoader

Thread 6:

0 libsystem_kernel.dylib 0x365ef004 0x365ee000 + 4100

1 libsystem_kernel.dylib 0x365ef1fa 0x365ee000 + 4602

2 CoreFoundation 0x369bd3ec 0x36930000 + 578540

3 CoreFoundation 0x369bc124 0x36930000 + 573732

4 CoreFoundation 0x3693f49e 0x36930000 + 62622

5 CoreFoundation 0x3693f366 0x36930000 + 62310

6 Foundation 0x32591bb2 0x32581000 + 68530

7 Foundation 0x32591a7a 0x32581000 + 68218

8 Foundation 0x3262558a 0x32581000 + 673162

9 libsystem_c.dylib 0x32f3772e 0x32f29000 + 59182

10 libsystem_c.dylib 0x32f375e8 0x32f29000 + 58856

Thread 7 name: com.apple.CFSocket.private

Thread 7:

0 libsystem_kernel.dylib 0x365ff570 0x365ee000 + 71024

1 CoreFoundation 0x369c163a 0x36930000 + 595514

2 libsystem_c.dylib 0x32f3772e 0x32f29000 + 59182

3 libsystem_c.dylib 0x32f375e8 0x32f29000 + 58856

Thread 4 crashed with ARM Thread State:

r0: 0x00000015    r1: 0x00000000      r2: 0x00000002      r3: 0x002ec510

r4: 0x00000000    r5: 0x0000000a      r6: 0x0010a8e8      r7: 0x03f4ac9c

r8: 0x37cfef2f    r9: 0x00000009     r10: 0x002ec510     r11: 0x00000122

ip: 0x3e61d63c    sp: 0x03f4ac88      lr: 0x34938075      pc: 0x34937e8a

cpsr: 0x00000030

How I fixed this error?

Thanks in advances...

iphone
addressbook
asked on Stack Overflow Sep 10, 2012 by ios • edited Sep 10, 2012 by Pratyusha Terli

1 Answer

0

The best approach to find the cause of the problem depends on whether you are still developing and have the code or whether this is a crash report from iTunes.

While there is a detailed Apple doc on the ARM registers here http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARMv6FunctionCallingConventions.html it does not really help to locate the problem.

If you have the code and you are still developing I would suggest you need to put NSLogs in the code and/or do some debugging.

If it's a crash report from iTunes the best is to follow Apple's guide on crash report here http://developer.apple.com/library/ios/#technotes/tn2151/_index.html.

This is the main idea as described by Apple:

If you get crash logs off a device through Xcode's Organizer window, then they will be symbolicated for you automatically after a few seconds. Otherwise you will need to symbolicate the .crash file yourself by importing it to the Xcode Organizer. Open the Xcode Organizer, select the “Devices” tab, select “Device Logs” under “LIBRARY” on the top of the sidebar, click the "Import" button and select the .crash file.

Basically, all you need to do in this case is drag and drop the crash report into xCode, but make sure you have the dSym file so xCode can xymbolicate the crash report with the correct version of the build of your app. To do this you need to "build and archive" each distributed app version! ps the video describing all the detail is in session 317...

answered on Stack Overflow Sep 10, 2012 by user387184 • edited Sep 10, 2012 by user387184

User contributions licensed under CC BY-SA 3.0