firebase-ios-sdk: Segmentation Fault: 11 after upgrading past 6.32.0
[REQUIRED] Step 1: Describe your environment
- Xcode version: 12.0.0, 11.7, 12.2.0 Beta
- Firebase SDK version: 6.32.2 upward (latest tested 6.34.0)
- Firebase Component: Crashlytics, RemoteConfig, Analytics, Performance, Auth, AppDistribution
- Installation method:
CocoaPods
Output of cat Podfile.lock | grep Firebase:
- Firebase/Analytics (6.34.0):
- Firebase/Core
- Firebase/AppDistribution (6.34.0):
- Firebase/CoreOnly
- FirebaseAppDistribution (~> 0.9.3)
- Firebase/Auth (6.34.0):
- Firebase/CoreOnly
- FirebaseAuth (~> 6.9.2)
- Firebase/Core (6.34.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 6.9.0)
- Firebase/CoreOnly (6.34.0):
- FirebaseCore (= 6.10.4)
- Firebase/Crashlytics (6.34.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 4.6.2)
- Firebase/Performance (6.34.0):
- Firebase/CoreOnly
- FirebasePerformance (~> 3.3.1)
- Firebase/RemoteConfig (6.34.0):
- Firebase/CoreOnly
- FirebaseRemoteConfig (~> 4.9.1)
- FirebaseABTesting (4.2.0):
- FirebaseCore (~> 6.10)
- FirebaseAnalytics (6.9.0):
- FirebaseCore (~> 6.10)
- FirebaseInstallations (~> 1.7)
- FirebaseAppDistribution (0.9.3):
- FirebaseCore (~> 6.10)
- FirebaseInstallations (~> 1.6)
- FirebaseAuth (6.9.2):
- FirebaseCore (~> 6.10)
- FirebaseCore (6.10.4):
- FirebaseCoreDiagnostics (~> 1.6)
- FirebaseCoreDiagnostics (1.7.0):
- FirebaseCrashlytics (4.6.2):
- FirebaseCore (~> 6.10)
- FirebaseInstallations (~> 1.6)
- FirebaseInstallations (1.7.0):
- FirebaseCore (~> 6.10)
- FirebasePerformance (3.3.1):
- FirebaseCore (~> 6.9)
- FirebaseInstallations (~> 1.5)
- FirebaseRemoteConfig (~> 4.7)
- FirebaseRemoteConfig (4.9.1):
- FirebaseABTesting (~> 4.2)
- FirebaseCore (~> 6.10)
- FirebaseInstallations (~> 1.6)
- Firebase/Analytics (= 6.34.0)
- Firebase/AppDistribution (= 6.34.0)
- Firebase/Auth (= 6.34.0)
- Firebase/Crashlytics (= 6.34.0)
- Firebase/Performance (= 6.34.0)
- Firebase/RemoteConfig (= 6.34.0)
- Firebase
- FirebaseABTesting
- FirebaseAnalytics
- FirebaseAppDistribution
- FirebaseAuth
- FirebaseCore
- FirebaseCoreDiagnostics
- FirebaseCrashlytics
- FirebaseInstallations
- FirebasePerformance
- FirebaseRemoteConfig
Firebase: c23a36d9e4cdf7877dfcba8dd0c58add66358999
FirebaseABTesting: 8a9d8df3acc2b43f4a22014ddf9f601bca6af699
FirebaseAnalytics: 3bb096873ee0d7fa4b6c70f5e9166b6da413cc7f
FirebaseAppDistribution: 3b615c5fba5953351c5c96ca03217d15b0ee85d2
FirebaseAuth: c92d49ada7948d1a23466e3db17bc4c2039dddc3
FirebaseCore: d3a978a3cfa3240bf7e4ba7d137fdf5b22b628ec
FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1
FirebaseCrashlytics: 1a747c9cc084a24dc6d9511c991db1cd078154eb
FirebaseInstallations: 466c7b4d1f58fe16707693091da253726a731ed2
FirebasePerformance: e325a8ee84a6a3d89c0be049390ed6c1775cce22
FirebaseRemoteConfig: 35a729305f254fb15a2e541d4b36f3a379da7fdc
[REQUIRED] Step 2: Describe the problem
After upgrading to Firebase 6.32.2 or later from 6.32.0, we get intermittent crashes in what seems to be the iOS internal networking stack. We are seeing Segmentation Fault: 11 crashes in networking-related code within Alamofire, URLSession as well as Kingfisher, all without updating any of the SDKs. When downgrading to 6.32.0 again everything works fine, so it’s related to Firebase.
Steps to reproduce:
The issue happens rather randomly during what used to be normal usage of the app, but seems to be consistently related to networking code looking at the crash logs.
I attached two crash logs:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 53 (22 by maintainers)
Thank a lot for such useful stack traces. After a lot of reads, I think this crash is related to NSURLSession not compatible with KVO on the property ‘state’. Recently Firebase Performance started observing on the ‘state’ property to identify the completion of the network request and that seems error prone (This was required because of iOS14).
Reference to similar kind of crash: https://github.com/AFNetworking/AFNetworking/issues/1477, https://github.com/pinterest/PINRemoteImage/issues/390
To mitigate this, we will remove the KVO based implementation with an alternate mechanism to stop these crashes from occurring.
Thanks for the report. In the most recent version of Firebase performance, we started using KVO to measure the completion of the network request. Not sure if this is conflicting with Alamofire. Can someone provide the following details?
We have already fixed a potential vulnerable code and this is expected to release soon. My guess is that this issue should be resolved with the fix. Will keep the thread posted.
Closing now that the fix is out in FirebasePerformance 3.3.2.
One clarification is that we only released FirebasePerformance 7.0.1 for the CocoaPods distribution. Other distributions will include the fix in the upcoming 7.1.0 targeted to release next week.
@petrykDima we have removed everything from the Firebase suite that was not 💯 necessary and will not be back any time soon …
@paulb777 I see that this fix is going in the major v7 update- any chance we can also get it in a v6 patch for those not immediately upgrading to v7? Our project was going to wait a little while before making the jump for various reasons.
We have released Firebase performance version 7.0.1 that removes the KVO implementation. Please update to the recent version of Firebase Performance to get away from the crashes users are experiencing.
Thanks a lot of staying up and providing details information that enabled us to know about the issue with the Apple framework.
I am also seeing 1000’s of crashes per day from my users with 7.0 (update went out 2 days ago). I have to revert my app back with an emergency update, and customers are pissed. The crashes happen randomly within the app and there are no set repro steps. Sometimes it happens when just opening views or pressing buttons that have no network calls associated with them. I am using Alamofire 5.3.0. Here’s the trace:
We have released FirebasePerformance 3.3.2 which reverted the KVO changes. Can you update FirebasePerformance to 3.3.2 and see if that fixes the issue?
We are planning to bring back KVO (to handle network request completion) along with the potential fix for Firebase 7.x.x.
We released new version of our app with Firebase 6.34.0 still but without Firebase Performance - no crashes so far, everything seems okay. That means the problem is in Firebase Performance and wasn’t present in 6.33.0. 😃
@tspecht We have added a potential fix to this issue in the upcoming release expected to go out in the next few days. In the meanwhile, we will also to continue to see if there are any other defensive coding we can bring in to avoid such issues.
The root cause of the issue is that we introduced a KVO based identification of the network request completeness and that seem to have some conflicts.