[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Auth crashes with TrustKit #3742

Closed
thetminko opened this issue Sep 2, 2019 · 13 comments
Closed

Firebase Auth crashes with TrustKit #3742

thetminko opened this issue Sep 2, 2019 · 13 comments

Comments

@thetminko
Copy link
thetminko commented Sep 2, 2019

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.3 (10G8)
  • Firebase SDK version: 5.20.2, 6.2.2, 6.7.0
  • Firebase Component: Auth (Auth, Core, Database, Firestore, Messaging, Storage, etc)
  • Component version: 5.20.2, 6.2.2, 6.7.0
  • TrustKit 1.6.2

[REQUIRED] Step 3: Describe the problem

Firebase Auth crashes when using TrustKit in the project with enabled swizzling

Steps to reproduce:

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

  1. Install Firebase/Auth and TrustKit using Cocoa Pods
  2. Init TrustKit with swizzling enabled
  3. Exec PhoneAuthProvider.provider().verifyPhoneNumber(...)
  4. App crash

View my sample project
https://github.com/thetminko/FirebaseAuthTrustKit

Console Logs:

2019-08-28 16:20:47.499384+0800 FirebaseAuthTrustKit[21828:4910670] === TrustKit: Proxy-ing NSURLSessionDelegate: GTMSessionFetcher 2019-08-28 16:20:47.499766+0800 FirebaseAuthTrustKit[21828:4910670] Fetcher delegate class: TSKNSURLSessionDelegateProxy 2019-08-28 16:20:47.500185+0800 FirebaseAuthTrustKit[21828:4910670] Fetcher made an extra session: GTMSessionFetcher 0x137a03400 2019-08-28 16:20:47.500357+0800 FirebaseAuthTrustKit[21828:4910670] Couldn't assign delegate. 2019-08-28 16:20:47.504906+0800 FirebaseAuthTrustKit[21828:4910670] Fetcher delegate class: TSKNSURLSessionDelegateProxy 2019-08-28 16:20:47.505126+0800 FirebaseAuthTrustKit[21828:4910670] -[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance 0x137a03400 2019-08-28 16:20:47.505945+0800 FirebaseAuthTrustKit[21828:4910670] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance 0x137a03400' *** First throw call stack: (0x193e5a98c 0x1930339f8 0x193d771c8 0x193e601d4 0x193e61e6c 0x104e630c0 0x104e40df8 0x104e3d634 0x104defb80 0x104df2848 0x104df1eb4 0x104def444 0x104e13d5c 0x104dec9a8 0x104dec748 0x104de6324 0x105058c78 0x105067480 0x104de625c 0x104de5d34 0x193e62010 0x193d43be0 0x104e7b2e4 0x104e79f40 0x193d463c8 0x104e79d48 0x104e7b130 0x1050576f4 0x105058c78 0x1050666fc 0x193dec32c 0x193de7264 0x193de67c0 0x195fe779c 0x1c08e5c38 0x104dd9de4 0x1938aa8e0) libc++abi.dylib: terminating with uncaught exception of type NSException

Stack Trace

thread #1, queue = 'com.google.firebase.auth.globalWorkQueue', stop reason = signal SIGABRT frame #0: 0x00000001939f70dc libsystem_kernel.dylib__pthread_kill + 8 
frame #1: 0x0000000193a749b0 libsystem_pthread.dylibpthread_kill$VARIANT$armv81 + 296 
frame #2: 0x000000019394fea8 libsystem_c.dylibabort + 140
frame #3: 0x000000019301c788 libc++abi.dylibabort_message + 132 
frame #4: 0x000000019301c934 libc++abi.dylibdefault_terminate_handler() + 308 
frame #5: 0x0000000193033e00 libobjc.A.dylib_objc_terminate() + 124 
frame #6: 0x0000000193028838 libc++abi.dylibstd::__terminate(void (*)()) + 16 
frame #7: 0x00000001930288c4 libc++abi.dylibstd::terminate() + 84 
frame #8: 0x0000000193033d5c libobjc.A.dylibobjc_terminate + 12 
frame #9: 0x0000000105058c8c libdispatch.dylib_dispatch_client_callout + 36 
frame #10: 0x0000000105067480 libdispatch.dylib`_dispatch_lane_barrier_sync_invoke_and_complete + 124
frame #11: 0x0000000104de625c FirebaseAuthTrustKit-[FIRAuth setAPNSToken:type:](self=0x0000000282735360, _cmd="setAPNSToken:type:", token=32 bytes, type=FIRAuthAPNSTokenTypeUnknown) at FIRAuth.m:1371:3 
frame #12: 0x0000000104de5d34 FirebaseAuthTrustKit-[FIRAuth application:didRegisterForRemoteNotificationsWithDeviceToken:](self=0x0000000282735360, _cmd="application:didRegisterForRemoteNotificationsWithDeviceToken:", application=0x0000000135d02910, deviceToken=32 bytes) at FIRAuth.m:1336:3 
frame #13: 0x0000000193e62010 CoreFoundation__invoking___ + 144 
frame #14: 0x0000000193d43be0 CoreFoundation-[NSInvocation invoke] + 292 
frame #15: 0x0000000104e7b2e4 FirebaseAuthTrustKit__93-[GULAppDelegateSwizzler application:donor_didRegisterForRemoteNotificationsWithDeviceToken:]_block_invoke(.block_descriptor=0x000000016b02e8d0, interceptor=0x0000000282735360) at GULAppDelegateSwizzler.m:849:37 
frame #16: 0x0000000104e79f40 FirebaseAuthTrustKit__72+[GULAppDelegateSwizzler notifyInterceptorsWithMethodSelector:callback:]_block_invoke(.block_descriptor=0x000000016b02e830, key=@"GUL_0x282735360", obj=0x000000028142ef30, stop=NO) at GULAppDelegateSwizzler.m:680:7 
frame #17: 0x0000000193d463c8 CoreFoundation-[__NSFrozenDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 176 
frame #18: 0x0000000104e79d48 FirebaseAuthTrustKit+[GULAppDelegateSwizzler notifyInterceptorsWithMethodSelector:callback:](self=GULAppDelegateSwizzler, _cmd="notifyInterceptorsWithMethodSelector:callback:", methodSelector="application:didRegisterForRemoteNotificationsWithDeviceToken:", callback=0x0000000104e7b1c4) at GULAppDelegateSwizzler.m:667:3 
frame #19: 0x0000000104e7b130 FirebaseAuthTrustKit-[GULAppDelegateSwizzler application:donor_didRegisterForRemoteNotificationsWithDeviceToken:](self=0x00000002816286e0, _cmd="application:didRegisterForRemoteNotificationsWithDeviceToken:", application=0x0000000135d02910, deviceToken=32 bytes) at GULAppDelegateSwizzler.m:840:3 
frame #20: 0x00000001050576f4 libdispatch.dylib_dispatch_call_block_and_release + 24 
frame #21: 0x0000000105058c78 libdispatch.dylib_dispatch_client_callout + 16 
frame #22: 0x00000001050666fc libdispatch.dylib_dispatch_main_queue_callback_4CF + 1360 
frame #23: 0x0000000193dec32c CoreFoundation__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 
frame #24: 0x0000000193de7264 CoreFoundation__CFRunLoopRun + 1924 
frame #25: 0x0000000193de67c0 CoreFoundationCFRunLoopRunSpecific + 436 
frame #26: 0x0000000195fe779c GraphicsServicesGSEventRunModal + 104 
frame #27: 0x00000001c08e5c38 UIKitCoreUIApplicationMain + 212 
frame #28: 0x0000000104dd9de4 FirebaseAuthTrustKitmain at AppDelegate.swift:14:7 
frame #29: 0x00000001938aa8e0 libdyld.dylib`start + 4

Podfile

platform :ios, '10.0'
target 'FirebaseAuthTrustKit' do
  pod 'Firebase/Auth', '~> 6.2.0'
  pod 'TrustKit', '~> 1.6.2'
end
@morganchen12
Copy link
Contributor
  1. Do you have -ObjC in your Other Linker Flags under the Build Settings tab of your target in Xcode?
  2. What version of GTMSessionFetcher are you using?

@thetminko
Copy link
Author

Hi @morganchen12

  1. I do have -ObjC in Other Linker Flags under Build Settings for the target

Screenshot 2019-09-04 at 10 42 47 AM

  1. I do not explicitly install GTMSessionFetcher. I only have Firebase/Auth and TrustKit in my Podfile.
    See my Podfile: https://github.com/thetminko/FirebaseAuthTrustKit/blob/master/Podfile#L7

However, there is an internal dependency, GTMSessionFetcher, under Firebase/Auth.
See here: https://github.com/thetminko/FirebaseAuthTrustKit/blob/master/Podfile.lock#L12

@morganchen12
Copy link
Contributor

Can you try updating the version of GTMSessionFetcher?

@thetminko
Copy link
Author

@morganchen12 u mean updating the internal dependency of FirebaseAuth module?

@paulb777
Copy link
Member
paulb777 commented Sep 4, 2019

It looks like GTMSessionFetcher version the latest from the Podfile.lock - https://github.com/thetminko/FirebaseAuthTrustKit/blob/master/Podfile.lock#L31

Something else is going on.

@paulb777
Copy link
Member
paulb777 commented Sep 4, 2019

I'm able to reproduce the crash. Thanks for providing the sample!

Based on the type of delegateDispatcher in this screen shot, it looks like a problem triggered by TrustKit's swizzling.

image

@thetminko
Copy link
Author

@paulb777 Thanks and appreciate for helping! May I ask if I am logging this issue at the right place or should I log this issue to TrustKit?

@paulb777
Copy link
Member
paulb777 commented Sep 4, 2019

@thetminko I don't fully understand the issue, and it's still possible there's an issue with Firebase's swizzling. However, based on the data we have so far, it seems more likely to be a TrustKit issue. I recommend logging it to TrustKit.

@thetminko
Copy link
Author
thetminko commented Sep 4, 2019

@paulb777 Thanks for the recommendation. I forgot to mention one thing. Firebase Messaging is actually working well with TrustKit swizzling. I could receive notifications even with TrustKit enabled. So, does it mean that the issue probably lie in the Firebase Auth module?

@paulb777
Copy link
Member
paulb777 commented Sep 4, 2019

I suspect it's because FirebaseAuth uses GTMSessionFetcher, but FirebaseMessaging does not. And the it looks like TrustKit's swizzling is breaking the functionality of GTMSessionFetcher.

@thetminko
Copy link
Author

Hi @paulb777, thanks for the explanation. I have logged the issue in TrustKit as well. Let me open this issue till I get a confirmation from TrustKit about a fix. Thanks!

@thetminko
Copy link
Author

@paulb777 Sadly, TrustKit is not going to fix this issue and their suggestion is to turn off the TrustKit swizzling. I had a use case where I could not so I think I have to look for some alternatives. Thanks for the support!

@paulb777
Copy link
Member
paulb777 commented Sep 9, 2019

@thetminko Thanks for sharing the investigation. Good luck solving your use case!

@firebase firebase locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants