WorryFree Computers   »   [go: up one dir, main page]

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

Crash in App Check token fetch with force refresh #8544

Closed
mikehardy opened this issue Aug 18, 2021 · 5 comments · Fixed by #8549
Closed

Crash in App Check token fetch with force refresh #8544

mikehardy opened this issue Aug 18, 2021 · 5 comments · Fixed by #8549

Comments

@mikehardy
Copy link
Contributor

Step 0: Are you in the right place?

  • For issues or feature requests related to the code in this repository
    file a Github issue.
    • If this is a feature request please use the Feature Request template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general (non-iOS) Firebase discussion, use the firebase-talk
    google group.
  • For backend issues, console issues, and other non-SDK help that does not fall under one
    of the above categories, reach out to
    Firebase Support.
  • Once you've read this section and determined that your issue is appropriate for
    this repository, please delete this section.

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.5.1
  • Firebase SDK version: 8.5.0 (but I scanned commits through 8.6.0, doesn't look addressed)
  • Installation method: CocoaPods (select one)
  • Firebase Component: App Check

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

Send YES for "forceRefresh" argument in this method

(DLog is just a wrapper for standard logging, use what you need)

Relevant Code:

- getToken
                  : (FIRApp *)firebaseApp
                  : (BOOL)forceRefresh) {
  FIRAppCheck *appCheck = [FIRAppCheck appCheckWithApp:firebaseApp];
  [appCheck tokenForcingRefresh:NO
                     completion:^(FIRAppCheckToken *_Nullable token, NSError *_Nullable error) {
                       if (error != nil) {
                         // Handle any errors if the token was not retrieved.
                         DLog(@"Unable to retrieve App Check token: %@", error);
                         return;
                       }
                       if (token == nil) {
                         DLog(@"Unable to retrieve App Check token.");
                         return;
                       }
                     DLog(@"fetched token successfully");
                     }];
}
App crashed: Exception was thrown: 
NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
(
        0   CoreFoundation                      0x00007fff20422faa __exceptionPreprocess + 226
        1   libobjc.A.dylib                     0x00007fff20193ff5 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff204a1523 _CFThrowFormattedException + 194
        3   CoreFoundation                      0x00007fff204ac91d -[__NSPlaceholderDictionary initWithCapacity:].cold.1 + 0
        4   CoreFoundation                      0x00007fff2048f4c6 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 251
        5   CoreFoundation                      0x00007fff20421c42 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49
        6   testing                             0x000000010ff2525a -[FPersistentConnection sendAppCheckToken:] + 154
        7   testing                             0x000000010ff251a1 -[FPersistentConnection refreshApp<…>

No crash if you send NO in there

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@maksymmalyhin
Copy link
Contributor

@mikehardy Thank you for the report.

Based on the provided stack trace it looks like the crash happens in Firebase Database. Could you please confirm that you are using Firebase Database in your app?

@mikehardy
Copy link
Contributor Author

Hi @maksymmalyhin ! I'm a maintainer of react-native-firebase, and we're the sanctioned bridge between the native SDKs and the react-native ecosystem, so our e2e test harness uses - to my best estimate - something like 98% of the entire API surface area of the full SDK :-) https://github.com/invertase/react-native-firebase/runs/3355573480?check_suite_focus=true#step:21:11

On iOS specifically we are not just using the database module, but we are using it against the emulator: https://github.com/invertase/react-native-firebase/blob/af336a3310d2653fe70879cd0729fba3469b15de/tests/app.js#L48-L52 - though removing that line and hitting the cloud is possible / okay to do / but untested for this issue, not sure if it has the same problem.

You may see our full install set here https://github.com/invertase/react-native-firebase/blob/master/tests/ios/Podfile.lock - that's not a perma-link so versions will change shortly as I adopt 8.6.0 over in our repo but it's reasonably correct for triage here I believe.

Let me know if there's anything else you need to reproduce - I know frequently the reproduction is the hardest part....

@maksymmalyhin
Copy link
Contributor

Thank you for the provided information. I may adjust the issue title to be more precise.

I can see the reason of the issue. It is an unfortunate typo and lack of solid tests in this code section. We will provide a fix.

@maksymmalyhin
Copy link
Contributor

cc @schmidt-sebastian

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants