Crash on UserService:logout sync method

calling logout on the UserService occasionally crashes the application with the iOS SDK (version 4.0.15).
Relevant part of the crash dump is here:


Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x185b797f4 objc_object::release() + 16
1 Call The Staff 0x102fcbd14 -[UserService onLogout:] (UserService.m:573)
2 Call The Staff 0x102fc9264 -[UserService logout] (UserService.m:203)

Thanks!

Hi Joshua,

In the sources I see this line:

[backendless.headers removeObjectForKey:BACKENDLESS_USER_TOKEN];

But I’m not sure how executing it leads to a crash.
Are you able to reproduce it?

I’ve checked and everything works fine.
If you’re able to reproduce it, please share it with us (you can send the achieved project to support@backendless.com).

Regards, Olga

I forgot the source was available! Good to look at, thanks for the link.

I’ll try to put together a minimal reproducer. to send your way. I agree - that line (and the lines right around it) don’t seem like they would cause any problems. The release of ‘self.currentUser’ is the only thing that may be an issue? I don’t really see how it could be though unless the reference count is already 0 from somewhere else in the process. The stack trace doesn’t really show how that could be though (since the only other place in the Backendless code that is touched, from what I can see, is from the logout method at line 192. Just in case this shed any other light, the full stack is here from a crash I just got to happen this morning:


Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x1831b97f4 objc_object::release() + 16
1  Call The Staff                 0x1040e1490 -[UserService onLogout:] (UserService.m:573)
2  Call The Staff                 0x1040de9e0 -[UserService logout] (UserService.m:203)
3  Call The Staff                 0x1040aa8e8 BackendlessManager.logout() -> () (BackendlessManager.swift:253)
4  Call The Staff                 0x1040d0eb4 specialized HomeViewController.handleButtonPress(sender : UIButton) -> () (HomeViewController.swift:75)
5  Call The Staff                 0x1040d06b4 @objc HomeViewController.handleButtonPress(sender : UIButton) -> () (HomeViewController.swift)
6  UIKit                          0x18d0cc20c -[UIApplication sendAction:to:from:forEvent:] + 96
7  UIKit                          0x18d0cc18c -[UIControl sendAction:to:forEvent:] + 80
8  UIKit                          0x18d0b6f4c -[UIControl _sendActionsForEvents:withEvent:] + 440
9  UIKit                          0x18d0cba80 -[UIControl touchesEnded:withEvent:] + 576
10 UIKit                          0x18d717ec8 _UIGestureEnvironmentSortAndSendDelayedTouches + 4280
11 UIKit                          0x18d713488 _UIGestureEnvironmentUpdate + 1196
12 UIKit                          0x18d712f88 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 404
13 UIKit                          0x18d7120e4 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 276
14 UIKit                          0x18d0c6a54 -[UIWindow sendEvent:] + 3180
15 UIKit                          0x18d098078 -[UIApplication sendEvent:] + 340
16 UIKit                          0x18d9d7f98 __dispatchPreprocessedEventFromEventQueue + 2364
17 UIKit                          0x18d9da408 __handleEventQueueInternal + 4760
18 UIKit                          0x18d9d3574 __handleHIDEventFetcherDrain + 152
19 CoreFoundation                 0x183c30358 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
20 CoreFoundation                 0x183c302d8 __CFRunLoopDoSource0 + 88
21 CoreFoundation                 0x183c2fb60 __CFRunLoopDoSources0 + 204
22 CoreFoundation                 0x183c2d738 __CFRunLoopRun + 1048
23 CoreFoundation                 0x183b4e2d8 CFRunLoopRunSpecific + 436
24 GraphicsServices               0x1859dff84 GSEventRunModal + 100
25 UIKit                          0x18d0fb880 UIApplicationMain + 208
26 Call The Staff                 0x10407b6a8 main (AppDelegate.swift:16)
27 libdyld.dylib                  0x18367256c start + 4


and my method that is calling this doesn’t do anything with references to the user either:



func logout(){
        backendless.userService.logout()
        let fbManager: FBSDKLoginManager = FBSDKLoginManager()
        fbManager.logOut()
    }

I’ll see if I can get you a project to try out. Thanks!

what is your preferred way for me to send you a zip file and instructions for testing?

Joshua,

The best option would be sending the project with instructions to support@backendless.com.

Thanks

Also, please minimise your app as possible. The project should be minimal, complete and verifiable - e.g if the app crashes on logout, there shouldn’t be any code responsible for the push notifications (it requires your development team and app bundle id). It should be as simple as possible. Thanks.

Closed according to the user response in Slack.

I stripped out more from what I sent yesterday, and the crash has gone away. I’ll go through and see what triggers it when I add more in (pushes, database management, etc). Thanks! I think you can close the issue for now.

Hello Joshua,

Did you solve the problem?