Skip to content

IOS Bug, RNFBAuthModule.m - line 1146 -[RNFBAuthModule firebaseUserToDict:] com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS #3416

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

Closed
1 of 5 tasks
hiroyaiizuka opened this issue Apr 8, 2020 · 19 comments
Labels
platform: ios plugin: authentication Firebase Authentication Type: Stale Issue has become stale - automatically added by Stale bot Workflow: Waiting for User Response Blocked waiting for user response.

Comments

@hiroyaiizuka
Copy link

hiroyaiizuka commented Apr 8, 2020

Issue

IOS only bug.
App was crashed with title error log on Firebase Crashlystics.
We use Firebase Authentication with email, apple sign-in, facebook, and anonymous login.

error log is below.

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000b934e6ad0
-[RNFBAuthModule firebaseUserToDict:]```


## Project Files

N/A

### Javascript

N/A

#### `package.json`:

```json
# N/A

firebase.json for react-native-firebase v6:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "react-native": {
    "crashlytics_debug_enabled": true
  }
}

Environment

"react-native": "0.61.5",
"@react-native-firebase/app": "^6.3.4",
"@react-native-firebase/auth": "^6.3.4",
"@react-native-firebase/crashlytics": "^6.3.4",

  • Platform that you're experiencing the issue on:

    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:

    • 6.3.4

@russellwheatley
Copy link
Member

Hi @hiroyaiizuka, could you please provide a code sample of where the error occurs?

@russellwheatley russellwheatley added the Workflow: Waiting for User Response Blocked waiting for user response. label Apr 8, 2020
@mikehardy
Copy link
Collaborator

Additionally, if you've got a native code issue, it seems like you will need a native code fix, yes? That will necessarily be based off most current code, so you should start your testing based off current code. That's 6.4.0 for react-native-firebase, and firebase iOS SDKs 6.21.0 specified like so https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh#L33

Imagine the time wasted if the issue was already fixed and all you needed to do was specify a couple different numbers!

@hiroyaiizuka
Copy link
Author

@russellwheatley
@mikehardy

Thank you for your quick reply.

To tell you the truth, I'm not familiar with Native code..
So I have no idea why this error happens and where our code is bad and how to research next...
But I have recently upgraded rn-firebase to 6.3.4 and this error happened and the number of crash was increasing...

スクリーンショット_2020-04-12_19_51_53

(8.1.1 - 9.0.0 is our latest release, and upgraded rn firebase from 5.4.2 to 6.3.4)

As you taught me, I will upgrade rn-firebae to 6.4.0 !

@JeanPSF
Copy link

JeanPSF commented Apr 17, 2020

I updated and still getting the error.

@stale
Copy link

stale bot commented May 15, 2020

Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label May 15, 2020
@russellwheatley
Copy link
Member

russellwheatley commented May 20, 2020

Hey @hiroyaiizuka, do you have any further information regarding the crash?

Do you know which authentication route (e.g. facebook, anonymous, etc) is causing the majority of the errors?

Could you provide the full stack trace, please?

Has there been any improvement since upgrading to version 6.4.0?

@stale stale bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label May 20, 2020
@hiroyaiizuka
Copy link
Author

hiroyaiizuka commented May 22, 2020

full stack trace

Thank you for your reply!
To tell you the truth, no further information about this...
This bug has been started since 2020/March , and not happened in Android, and we just added Sign in With Apple at the same time.
So authentication route might be apple sign in. (not sure)

Here is the stackTrace.

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x1a63efb30 objc_msgSend + 16
1  CoreFoundation                 0x1a65ae2f4 -[NSDictionary allValues] + 72
2  BeatFit                        0x1005bf45c -[RNFBAuthModule firebaseUserToDict:] + 1146 (RNFBAuthModule.m:1146)
3  BeatFit                        0x1005be274 -[RNFBAuthModule promiseWithUser:rejecter:user:] + 1021 (RNFBAuthModule.m:1021)
4  libdispatch.dylib              0x1a63969a8 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x1a6397524 _dispatch_client_callout + 16
6  libdispatch.dylib              0x1a63495b4 _dispatch_main_queue_callback_4CF$VARIANT$mp + 904
7  CoreFoundation                 0x1a664f748 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8  CoreFoundation                 0x1a664a61c __CFRunLoopRun + 1724
9  CoreFoundation                 0x1a6649c34 CFRunLoopRunSpecific + 424
10 GraphicsServices               0x1b079338c GSEventRunModal + 160
11 UIKitCore                      0x1aa77c22c UIApplicationMain + 1932
12 BeatFit                        0x100266c80 main + 14 (main.m:14)
13 libdyld.dylib                  0x1a64d1800 start + 4
com.google.firebase.auth.globalWorkQueue
0  libsystem_kernel.dylib         0x1a64a5198 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x1a64a460c mach_msg + 72
2  libdispatch.dylib              0x1a6352c04 _dispatch_mach_send_and_wait_for_reply + 560
3  libdispatch.dylib              0x1a6352fcc dispatch_mach_send_with_result_and_wait_for_reply$VARIANT$mp + 52
4  libxpc.dylib                   0x1a62989d8 xpc_connection_send_message_with_reply_sync + 236
5  Security                       0x1a74f8d2c securityd_message_with_reply_sync + 96
6  Security                       0x1a75790a4 SecItemRawUpdate + 308
7  Security                       0x1a7577128 __SecItemAuthDoQuery_block_invoke + 364
8  Security                       0x1a75759b0 SecItemAuthDo + 124
9  Security                       0x1a7576358 SecItemAuthDoQuery + 552
10 Security                       0x1a7578eac SecItemUpdateWithError + 452
11 Security                       0x1a7573f50 SecOSStatusWith + 48
12 Security                       0x1a757646c SecItemUpdate + 144
13 BeatFit                        0x1003b4888 -[FIRAuthKeychainServices setItemWithQuery:attributes:error:] + 173 (FIRAuthKeychainServices.m:173)
14 BeatFit                        0x1003b4424 -[FIRAuthKeychainServices setData:forKey:error:] + 100 (FIRAuthKeychainServices.m:100)
15 BeatFit                        0x1003ab13c -[FIRAuth saveUser:error:] + 1836 (FIRAuth.m:1836)
16 BeatFit                        0x1003aa20c -[FIRAuth updateKeychainWithUser:error:] + 1577 (FIRAuth.m:1577)
17 BeatFit                        0x1003c7ee0 -[FIRUser updateKeychain:] + 514 (FIRUser.m:514)
18 BeatFit                        0x1003c723c __41-[FIRUser getAccountInfoRefreshingCache:]_block_invoke_2 + 414 (FIRUser.m:414)
19 BeatFit                        0x1003b068c __69-[FIRAuthBackendRPCImplementation postWithRequest:response:callback:]_block_invoke + 959 (FIRAuthBackend.m:959)
20 BeatFit                        0x100528808 __71-[GTMSessionFetcher invokeFetchCallbacksOnCallbackQueueWithData:error:]_block_invoke + 2494 (GTMSessionFetcher.m:2494)
21 libdispatch.dylib              0x1a63969a8 _dispatch_call_block_and_release + 24
22 libdispatch.dylib              0x1a6397524 _dispatch_client_callout + 16
23 libdispatch.dylib              0x1a63439d8 _dispatch_lane_serial_drain$VARIANT$mp + 916
24 libdispatch.dylib              0x1a6344294 _dispatch_lane_invoke$VARIANT$mp + 416
25 libdispatch.dylib              0x1a634d78c _dispatch_workloop_worker_thread + 588
26 libsystem_pthread.dylib        0x1a63e8b74 _pthread_wqthread + 272
27 libsystem_pthread.dylib        0x1a63eb740 start_wqthread + 8

@mikehardy
Copy link
Collaborator

I had a similar issue with Apple Auth firebase/firebase-ios-sdk#4561 - they smell the same. I now null check the username and the email before I call the apple login or the firebase get emails for user stuff. Perhaps with stricter checking on the arguments to each API call you would succeed, and/or breakpoints in the upstream iOS SDK code (it's open source actually) you could see what's happening

It really looks like an upstream issue but there's a chance not since the final stack seems to be in the callback handler here

@gearguy365
Copy link

facing the same issue with firebase SDK v6.13.0 and

react-native-firebase : 6.3.1
react-native : 0.61.5

@hiroyaiizuka are you experiencing the crashes with any particular version of iOS? in my case all the crashes occurred on users with iOS 13.4.1

@mikehardy
Copy link
Collaborator

@gearguy365 strongly recommend upgrade to react-native-firebase current (v7.x) and SDKs current (iOS is on 6.25.x now I think?) - should be the best path as troubleshooting old code will have everyone chasing already-fixed phantoms, specifically #3339 was massive, and it merged in react-native-firebase 6.4, there are likely others so getting current should be step 1

@oisu
Copy link

oisu commented Jun 18, 2020

@gearguy365
I'm working in the same project as @hiroyaiizuka and our case occurs only on iOS 13.

The breakdown is
46% iOS 13.5.1
45% iOS 13.4.1
7% iOS 13.3.1
2% Other

@hiroyaiizuka
Copy link
Author

hiroyaiizuka commented Jun 18, 2020

After upgrade react-native firebase latest version, error still happens 😥

   "@react-native-firebase/app": "^7.2.0",
   "@react-native-firebase/auth": "^8.0.4",

@mikehardy
Copy link
Collaborator

What's the result of a search for upstream issues in firebase-ios-sdk?
DId you look at the issue I linked and study the input parameters the APIs you are calling? Are you sure you are sending valid parameters (with the idea being, they may not be checking parameters carefully but you can avoid a crash by pre-checking them)?

@hiroyaiizuka
Copy link
Author

hiroyaiizuka commented Jun 19, 2020

@mikehardy

Thank you for your reply!

I read this issue and in next release, we will add strict null check in email, password.

As you pointed out , we also doubt the possibility that currentUser null problem might cause this.

const {currentUser} = this.props
const {email} = currentUser

Our codes included above, so we add

if(!currentUser){
  return null
}

and also add null check before calling auth API.

before:

  const res = await auth().currentUser.linkWithCredential(credential)

after:

  const user = await auth().currentUser
  if(!user){
    return null
  }

  const res = user.linkWithCredential(credential)

This change will be released 6/20 ~ 6/27.
So I will tell you the result of crash report.

Thank you for your kindness.

@hiroyaiizuka
Copy link
Author

@mikehardy

I upgraded latest firebase module and insert null checks where auth api are used, but crash still lasts...
This bug is nightmare...

@hiroyaiizuka
Copy link
Author

Out latest investigation revealed that all of the user's RAM was less than 200MB.
So this bugs might be related to lack of memory...

We will do further investigations.
スクリーンショット 2020-07-01 16 28 49

@stale
Copy link

stale bot commented Aug 8, 2020

Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Aug 8, 2020
@stale
Copy link

stale bot commented Aug 23, 2020

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 23, 2020
@Robiullah2244
Copy link

Is this issue fixed? I am getting so many crashes. What's the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: ios plugin: authentication Firebase Authentication Type: Stale Issue has become stale - automatically added by Stale bot Workflow: Waiting for User Response Blocked waiting for user response.
Projects
None yet
Development

No branches or pull requests

7 participants