App suddenly stops working with "EXC_BAD_ACCESS"

Hello there,
we are currently developing an app with your backend. Suddenly the app crashes on startup without any code changes. It happens in this part:


[backendless.userService isValidUserToken:
 ^(NSNumber *result) {
 if(backendless.userService.currentUser != nil){
 [self performSegueWithIdentifier:@"showRevealView" sender:self];
 }
 }
 error:^(Fault *fault) {
 _tapToStartLabel.text = @"Zum Starten tippen";
 }];

We call this inside viewDidAppear inside the first view controller. The callbacks are not reached at all. The stack trace looks like this:
http://support.backendless.com/public/attachments/b5e72aa198377e5798948c782a9cf3e1.png</img>
Any ideas? backendless.userService.currentUser returns the user object correctly. I assume it has something to do with the session.
Thanks for any suggestion!
Best regards,
Martin Pfannemüller

Hi Martin,

Try to use sync method instead async - and let us how it goes

Regards,
Slava

Hello Slava,

This is my new code:

 
 
 
 
 
 
 
 
NSNumber *validToken = [backendless.userService isValidUserToken]; 
 
 if([validToken boolValue] && backendless.userService.currentUser != nil){ 
 
 [self performSegueWithIdentifier:@"showRevealView" sender:self]; 
 
 }else{ 
 
 _tapToStartLabel.text = @"Zum Starten tippen"; 
 
 } 



I get the same EXC_BAD_ACCESS (code=2) error in the first line. The stack trace looks the same.

Thanks for your help.

Best regards,
Martin

If user hasn’t been logged in, then backendless.userService.currentUser == nil
and sync method [backendless.userService isValidUserToken] throws an exception, which you should catch:

    
    @try {
        NSNumber *validToken = [backendless.userService isValidUserToken];
        
        if([validToken boolValue] && backendless.userService.currentUser != nil){
            NSLog(@"YES");
            
        }else{
            NSLog(@"NO");
        }
    }
    
    @catch (Fault *fault) {
        NSLog(@"Server reported an error: %@", fault);
    }

Please try again with this fix.

And please download the latest libs from our github - https://github.com/Backendless/ios-SDK/tree/master/SDK/lib (it is be fine if we will work with the same release)

We are using the latest Version (3.0.8). If we use your code the same error happens in line 3.

EDIT:
It has to do something with this session, I deleted the app from the device/simulator, and when I logged in again, it worked. The session restoring works now again too.

Okay I could reproduce the problem like this: This only happens if the session has expired. I set the expiration time to 60 seconds. I log in, close the app completely. After 60 seconds I reopen the app and get this error. Isn’t this the usual way of checking weather the token is still valid? Why does it not work then in this case?

As additional information with NSZombieEnabled I sometimes get the following output in the console:

Class _NSZombie_OS_dispatch_group is implemented in both ?? and ??. One of the two will be used. Which one is undefined.
or

Class _NSZombie_NSPathStore2 is implemented in both ?? and ??. One of the two will be used. Which one is undefined.

Hi Martin,

This issue is fixed - you can get the fixed lib from github.

Regards,
Slava

Hi Slava,

Great, thanks a lot for your great support!

Best regards,
Martin