1

My ios8 application is crash giving following logs

Incident Identifier:
CrashReporter Key:  
Hardware Model:      iPhone7,2
Process:         APP Beta [3203]
Path:            /private/var/mobile/Containers/Bundle/Application/B471AC73-68B1-425B-/APP Beta.app/APP Beta
Identifier:      com.product.APP
Version:         2.0.34
Code Type:       ARM-64
Parent Process:  launchd [1]

Date/Time:       2015-07-20T22:21:19Z
OS Version:      iPhone OS 8.4 (1243)
Report Version:  104

Exception Type:  SIGABRT
Exception Codes: #0 at 0x196d23270
Crashed Thread:  0

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x17045d2e0'

Last Exception Backtrace:
0   CoreFoundation                       0x00000001848942d8 <redacted> + 132
1   libobjc.A.dylib                      0x00000001965600e4 objc_exception_throw + 60
2   CoreFoundation                       0x000000018489b3a4 <redacted> + 0
3   CoreFoundation                       0x0000000184898154 <redacted> + 928
4   CoreFoundation                       0x000000018479accc _CF_forwarding_prep_0 + 92
5   UIKit                                0x0000000189a60a24 -[UITextField _textNeedsSanitizing:] + 148
6   UIKit                                0x000000018934a114 -[UITextField setText:] + 56
7   APP Beta                             0x00000001001c13b4 -[APPEditCardInformation initWithFrame:] + 1384
8   APP Beta                             0x0000000100182a60 -[APPEditViewController drawPrimaryView] + 568
9   APP Beta                             0x0000000100181234 -[APPEditViewController viewDidLoad] + 432
10  UIKit                                0x000000018930cc18 -[UIViewController loadViewIfRequired] + 692
11  UIKit                                0x000000018930c928 -[UIViewController view] + 32
12  UIKit                                0x00000001894af1f0 -[UINavigationController _startCustomTransition:] + 712
13  UIKit                                0x00000001893c1e84 -[UINavigationController _startDeferredTransitionIfNeeded:] + 468
14  UIKit                                0x00000001893c1c50 -[UINavigationController __viewWillLayoutSubviews] + 56
15  UIKit                                0x00000001893c1bd0 -[UILayoutContainerView layoutSubviews] + 200
16  UIKit                                0x00000001893096f4 -[UIView layoutSublayersOfLayer:] + 580
17  QuartzCore                           0x0000000188c45db8 -[CALayer layoutSublayers] + 152
18  QuartzCore                           0x0000000188c40820 <redacted> + 320
19  QuartzCore                           0x0000000188c406c4 <redacted> + 32
20  QuartzCore                           0x0000000188c3fe58 <redacted> + 276
21  QuartzCore                           0x0000000188c3fbd8 <redacted> + 528
22  QuartzCore                           0x0000000188c39300 <redacted> + 80
23  CoreFoundation                       0x000000018484c2a4 <redacted> + 32
24  CoreFoundation                       0x0000000184849230 <redacted> + 360
25  CoreFoundation                       0x0000000184849610 <redacted> + 836
26  CoreFoundation                       0x00000001847752d4 CFRunLoopRunSpecific + 396
27  GraphicsServices                     0x000000018e1cb6fc GSEventRunModal + 168
28  UIKit                                0x0000000189372f40 UIApplicationMain + 1488
29  APP Beta                             0x0000000100190bf4 -[NSInvocation mp_returnValue] + 23644
30  libdyld.dylib                        0x0000000196c0aa08 <redacted> + 4

Thread 0 Crashed:
0   libsystem_kernel.dylib               0x0000000196d23270 __pthread_kill + 8
1   libsystem_c.dylib                    0x0000000196c9ab18 abort + 112
2   APP Beta                             0x000000010067b9e0 -[FlurryPLCrashReporter generateLiveReportWithThread:] + 0
3   CoreFoundation                       0x0000000184894698 <redacted> + 692
4   libobjc.A.dylib                      0x00000001965603b4 <redacted> + 116
5   libc++abi.dylib                      0x0000000195d49bb4 <redacted> + 16
6   libc++abi.dylib                      0x0000000195d49478 <redacted> + 0
7   libobjc.A.dylib                      0x0000000196560204 <redacted> + 0
8   CoreFoundation                       0x000000018489b3a4 <redacted> + 0
9   CoreFoundation                       0x0000000184898154 <redacted> + 928
10  CoreFoundation                       0x000000018479accc _CF_forwarding_prep_0 + 92
11  UIKit                                0x0000000189a60a24 -[UITextField _textNeedsSanitizing:] + 148
12  UIKit                                0x000000018934a114 -[UITextField setText:] + 56
13  APP Beta                             0x00000001001c13b4 -[APPEditCardInformation initWithFrame:] + 1384
14  APP Beta                             0x0000000100182a60 -[APPEditViewController drawPrimaryView] + 568
15  APP Beta                             0x0000000100181234 -[APPEditViewController viewDidLoad] + 432
16  UIKit                                0x000000018930cc18 -[UIViewController loadViewIfRequired] + 692
17  UIKit                                0x000000018930c928 -[UIViewController view] + 32
18  UIKit                                0x00000001894af1f0 -[UINavigationController _startCustomTransition:] + 712
19  UIKit                                0x00000001893c1e84 -[UINavigationController _startDeferredTransitionIfNeeded:] + 468
20  UIKit                                0x00000001893c1c50 -[UINavigationController __viewWillLayoutSubviews] + 56
21  UIKit                                0x00000001893c1bd0 -[UILayoutContainerView layoutSubviews] + 200
22  UIKit                                0x00000001893096f4 -[UIView layoutSublayersOfLayer:] + 580
23  QuartzCore                           0x0000000188c45db8 -[CALayer layoutSublayers] + 152
24  QuartzCore                           0x0000000188c40820 <redacted> + 320
25  QuartzCore                           0x0000000188c406c4 <redacted> + 32
26  QuartzCore                           0x0000000188c3fe58 <redacted> + 276
27  QuartzCore                           0x0000000188c3fbd8 <redacted> + 528
28  QuartzCore                           0x0000000188c39300 <redacted> + 80
29  CoreFoundation                       0x000000018484c2a4 <redacted> + 32
30  CoreFoundation                       0x0000000184849230 <redacted> + 360
31  CoreFoundation                       0x0000000184849610 <redacted> + 836
32  CoreFoundation                       0x00000001847752d4 CFRunLoopRunSpecific + 396
33  GraphicsServices                     0x000000018e1cb6fc GSEventRunModal + 168
34  UIKit                                0x0000000189372f40 UIApplicationMain + 1488
35  APP Beta                             0x0000000100190bf4 -[NSInvocation mp_returnValue] + 23644
36  libdyld.dylib                        0x0000000196c0aa08 <redacted> + 4

Does anybody has any idea regarding this issue?

This is the function which I am calling in viewWillAppear

- (void)updateEditView {
    if (IS_IPAD) {
        float height = 0;
        float width = 0;
        if (INTERFACE_IS_PHONE || [[UIScreen mainScreen] bounds].size.height == 480) {
            height = HEIGHT;
            width = WIDTH;
        }
        else {
            if( [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] ==  UIInterfaceOrientationLandscapeRight) {
                if (IS_OS_8_OR_LATER) {
                    height = HEIGHT;
                    width = WIDTH;
                }
                else {
                    height = WIDTH;
                    width = HEIGHT;
                }
            }
            else {
                height = HEIGHT;
                width = WIDTH;
            }

        }
        navigationBar.frame = CGRectMake(navigationBar.frame.origin.x,    navigationBar.frame.origin.y, width, navigationBar.frame.size.height);

        titleLabel.frame = CGRectMake(50, 21, width - 100, 45);
        if (innerView == 1) {
            editAddress.frame = CGRectMake(0, 0, width, height);
            editAddress.userFullName.frame = CGRectMake(editAddress.userFullName.frame.origin.x, editAddress.userFullName.frame.origin.y, width - (2*editAddress.userFullName.frame.origin.x), editAddress.userFullName.frame.size.height);
            editAddress.streetAddress.frame = CGRectMake(editAddress.streetAddress.frame.origin.x, editAddress.streetAddress.frame.origin.y, width - (2*editAddress.streetAddress.frame.origin.x), editAddress.streetAddress.frame.size.height);
            editAddress.zipCode.frame = CGRectMake(editAddress.zipCode.frame.origin.x, editAddress.zipCode.frame.origin.y, width - (2*editAddress.zipCode.frame.origin.x), editAddress.zipCode.frame.size.height);
            editAddress.cityField.frame = CGRectMake(editAddress.cityField.frame.origin.x, editAddress.cityField.frame.origin.y, width/2 - (2*editAddress.cityField.frame.origin.x), editAddress.cityField.frame.size.height);
            editAddress.stateField.frame = CGRectMake(width/2 + 20, editAddress.stateField.frame.origin.y, width/2 - (2*20), editAddress.stateField.frame.size.height);
            editAddress.onlySeperator.frame = CGRectMake(width/2.0, 66 + 180, 1, 60);

            if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] ==  UIInterfaceOrientationLandscapeRight) {
                editAddress.saveButton.frame = CGRectMake(140, editAddress.saveButton.frame.origin.y, width - 2*140, editAddress.saveButton.frame.size.height);
            }
            else
                editAddress.saveButton.frame = CGRectMake(10, editAddress.saveButton.frame.origin.y, width - 20, editAddress.saveButton.frame.size.height);

        }
        else if (innerView == 2) {
            editCardInfo.frame = CGRectMake(0, 0, width, height);
            editCardInfo.onlySeperator.frame = CGRectMake(width/2.0, 66 + 120, 1, 60);

            editCardInfo.nameOnCard.frame = CGRectMake(editCardInfo.nameOnCard.frame.origin.x, editCardInfo.nameOnCard.frame.origin.y, width - (2*editCardInfo.nameOnCard.frame.origin.x), editCardInfo.nameOnCard.frame.size.height);
            editCardInfo.creditCardNumber.frame = CGRectMake(editCardInfo.creditCardNumber.frame.origin.x, editCardInfo.creditCardNumber.frame.origin.y, width - (2*editCardInfo.creditCardNumber.frame.origin.x), editCardInfo.creditCardNumber.frame.size.height);
            editCardInfo.expireDate.frame = CGRectMake(editCardInfo.expireDate.frame.origin.x, editCardInfo.expireDate.frame.origin.y, width/2 - (2*editCardInfo.expireDate.frame.origin.x), editCardInfo.expireDate.frame.size.height);
            editCardInfo.cvcNumber.frame = CGRectMake(width/2 + 20, editCardInfo.cvcNumber.frame.origin.y, width/2 - (2*20), editCardInfo.cvcNumber.frame.size.height);

            editCardInfo.creditCardImage.frame = CGRectMake(width - 20 - 33, editCardInfo.creditCardImage.frame.origin.y, editCardInfo.creditCardImage.frame.size.width, editCardInfo.creditCardImage.frame.size.height);

            if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] ==  UIInterfaceOrientationLandscapeRight) {
                editCardInfo.saveButton.frame = CGRectMake(140, editCardInfo.saveButton.frame.origin.y, width - 2*140, editCardInfo.saveButton.frame.size.height);
            }
            else
                editCardInfo.saveButton.frame = CGRectMake(10, editCardInfo.saveButton.frame.origin.y, width - 20, editCardInfo.saveButton.frame.size.height);

        }
        else if (innerView == 3) {

            editContactInfo.frame = CGRectMake(0, 0, width, height);

            editContactInfo.emailAddressField.frame = CGRectMake(editContactInfo.emailAddressField.frame.origin.x, editContactInfo.emailAddressField.frame.origin.y, width - 2*editContactInfo.emailAddressField.frame.origin.x, editContactInfo.emailAddressField.frame.size.height);

            editContactInfo.contactNumberField.frame = CGRectMake(editContactInfo.contactNumberField.frame.origin.x, editContactInfo.contactNumberField.frame.origin.y, width - 2*editContactInfo.contactNumberField.frame.origin.x, editContactInfo.contactNumberField.frame.size.height);

            if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] ==  UIInterfaceOrientationLandscapeRight) {
                editContactInfo.saveButton.frame = CGRectMake(140, editContactInfo.saveButton.frame.origin.y, width - 2*140, editContactInfo.saveButton.frame.size.height);
            }
            else
                editContactInfo.saveButton.frame = CGRectMake(10, editContactInfo.saveButton.frame.origin.y, width - 20, editContactInfo.saveButton.frame.size.height);
        }
    }
}

This issue is occurring when user is opening the app from background.

Stephan
  • 15,704
  • 7
  • 48
  • 63
Shrinivas Kulkarni
  • 492
  • 2
  • 5
  • 17
  • care to share some code? and perhaps you are doing something you should not if the crash is inside the component ... – PetrV Jul 24 '15 at 11:11
  • You are missing line numbers for your own calls, likely an issue with the dSYM generation in your build process. Also you should always show the complete crash report and also the relevant source code. – Kerni Jul 24 '15 at 11:20
  • I will attach the code. – Shrinivas Kulkarni Jul 24 '15 at 11:28
  • You try to send a `rangeOfCharacterFromSet:` to an NSMutableArray (the pointer in your code is probably not of type NSMutableArray but NSString or NSMutableString). So Look for occurrences of the method and make sure the object really is an NSString and not an NSMutableArray. – HAS Jul 11 '16 at 16:39

1 Answers1

2

tl;dr it is an memory issue, the string is not valid anymore.

you can simple reproduce the stacktrace with the following steps / code:

// 1) create a property to enforce the memory issue
@property (nonatomic, assign) NSString* dumpString

now we just trick the compiler a little bit...

// 2) create an invalid "string"object, in this case, a view :)
NSDictionary* dict = @{@"key": [[UIView alloc] init]};
// 3) because objectForKey: will return an id, the runtime has no idea that it is no string
self.dumpString = [dict objectForKey:@"key"];
// 4) here is your crash, when we set the value to the textfield, the textfield tries to sanitize the string and runs into an invalid memory layout
self.textField.text = self.dumpString;
xarfk
  • 21
  • 2