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

Segmentation Fault: 11 after upgrading past 6.32.0 #6734

Closed
tspecht opened this issue Oct 15, 2020 · 53 comments
Closed

Segmentation Fault: 11 after upgrading past 6.32.0 #6734

tspecht opened this issue Oct 15, 2020 · 53 comments
Assignees

Comments

@tspecht
Copy link

tspecht commented Oct 15, 2020

[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:

crash_report_1.txt
crash_report_2.txt

@morganchen12
Copy link
Contributor

I suspect Performance is doing something bad. Can you try excluding Performance?

@maksymmalyhin
Copy link
Contributor

@tspecht Sorry you have the issue.

From the first glance the crash indicates a concurrent memory access somewhere around NSBlockOperation or memory management issue. The issue may be exposed by changes in Firebase Performance SDK but it would not necessarily mean that Firebase Performance is the root reason. Options I would suggest to try:

  1. Run your app/tests with Thread, Address sanitizers and Zombie Objects:
    Screen Shot 2020-10-15 at 12 12 53 PM
  2. Try to instrumentation for Firebase Performance

Please share the results so we can think of the next steps.

Note: It also may be related to #6713.

@tspecht
Copy link
Author

tspecht commented Oct 15, 2020

@maksymmalyhin I did try running with the different checkers, unfortunately nothing interesting came out of this. Not sure what you mean by point #2?

@maksymmalyhin
Copy link
Contributor

@tspecht I mean setting isInstrumentationEnabled. It allows you to keep custom performance traces(if you use them) but disable metrics collected automatically that imply swizzling, etc.

@tspecht
Copy link
Author

tspecht commented Oct 15, 2020

@maksymmalyhin currently running our CI steps a bunch of times which takes a while, first pass with isInstrumentationEnabled = false has been looking good though, so might have fixed the crashes. Will post another update in ~2h

@maksymmalyhin
Copy link
Contributor

@tspecht Thank you!

@tspecht
Copy link
Author

tspecht commented Oct 15, 2020

@maksymmalyhin ran it two additional times and still seeing crashes:

crash_log_3.txt

@maksymmalyhin
Copy link
Contributor

@tspecht is the crash with isInstrumentationEnabled = false ?

@tspecht
Copy link
Author

tspecht commented Oct 15, 2020

@maksymmalyhin unfortunately yes, calling the following as part of my AppDelegate.didFinishLaunching:

Performance.sharedInstance().isInstrumentationEnabled = false

@maksymmalyhin
Copy link
Contributor

@tspecht It most likely indicates that the crash is not related to Performance SDK. Just to be more sure on it, could you please test with Firebase Performance excluded from your app?

@tspecht
Copy link
Author

tspecht commented Oct 16, 2020

@maksymmalyhin we just finished running 5 builds in a row without the Firebase/Performance pod.

Previously we used to have a failure rate of roughly 2 out of 3 builds failing due to the crash mentioned above.
After removing Firebase/Performance we ran 5 builds in a row successfully without a single crash.

While this isn't proof, I think statistically speaking this indicates that Firebase/Performance really is to blame here.

@jimmyhoran
Copy link

jimmyhoran commented Oct 16, 2020

We ran into the same issue, so we had started exhaustively testing our builds to try an establish a trend. We were successful in semi-reliably reproducing the crash within 5 attempts of uninstalling, re-installing and launching the same application build.

We had recently updated Firebase/Crashlytics, Firebase/Analytics and Firebase/Performance from 6.31.0 to 6.34.0. After reverting back to 6.31.0, I can confidently say the issue is resolved for us.

If there's any additional information someone from Firebase needs to look into this, please let me know.
I'd be happy to provide any additional information to aid this being resolved in a future version 🙏

@Kaspik
Copy link

Kaspik commented Oct 16, 2020

We are seeing thousands of crashes on our latest app version due to Heap Corruption and we can't figure why as the logs are pretty unusable. We updated our app from 6.33 to 6.34 (6.33 was okay), here is a diff of our Podfile.lock if it helps:

  - Firebase/Analytics (6.33.0):		  - Firebase/Analytics (6.34.0):
    - Firebase/Core		    - Firebase/Core
  - Firebase/Core (6.33.0):		  - Firebase/Core (6.34.0):
    - Firebase/CoreOnly		    - Firebase/CoreOnly
    - FirebaseAnalytics (= 6.8.3)		    - FirebaseAnalytics (= 6.9.0)
  - Firebase/CoreOnly (6.33.0):		  - Firebase/CoreOnly (6.34.0):
    - FirebaseCore (= 6.10.3)		    - FirebaseCore (= 6.10.4)
  - Firebase/Crashlytics (6.33.0):		  - Firebase/Crashlytics (6.34.0):
    - Firebase/CoreOnly		    - Firebase/CoreOnly
    - FirebaseCrashlytics (~> 4.6.1)		    - FirebaseCrashlytics (~> 4.6.2)
  - Firebase/Messaging (6.33.0):		  - Firebase/Messaging (6.34.0):
    - Firebase/CoreOnly		    - Firebase/CoreOnly
    - FirebaseMessaging (~> 4.7.0)		    - FirebaseMessaging (~> 4.7.1)
  - Firebase/Performance (6.33.0):		  - Firebase/Performance (6.34.0):
    - Firebase/CoreOnly		    - Firebase/CoreOnly
    - FirebasePerformance (~> 3.3.0)		    - FirebasePerformance (~> 3.3.1)
  - FirebaseABTesting (4.2.0):		  - FirebaseABTesting (4.2.0):
    - FirebaseCore (~> 6.10)		    - FirebaseCore (~> 6.10)
  - FirebaseAnalytics (6.8.3):		  - FirebaseAnalytics (6.9.0):
    - FirebaseCore (~> 6.10)		    - FirebaseCore (~> 6.10)
    - FirebaseInstallations (~> 1.6)		    - FirebaseInstallations (~> 1.7)
    - GoogleAppMeasurement (= 6.8.3)		    - GoogleAppMeasurement (= 6.9.0)
    - GoogleUtilities/AppDelegateSwizzler (~> 6.7)		    - GoogleUtilities/AppDelegateSwizzler (~> 6.7)
    - GoogleUtilities/MethodSwizzler (~> 6.7)		    - GoogleUtilities/MethodSwizzler (~> 6.7)
    - GoogleUtilities/Network (~> 6.7)		    - GoogleUtilities/Network (~> 6.7)
    - "GoogleUtilities/NSData+zlib (~> 6.7)"		    - "GoogleUtilities/NSData+zlib (~> 6.7)"
    - nanopb (~> 1.30906.0)		    - nanopb (~> 1.30906.0)
  - FirebaseCore (6.10.3):		  - FirebaseCore (6.10.4):
    - FirebaseCoreDiagnostics (~> 1.6)		    - FirebaseCoreDiagnostics (~> 1.6)
    - GoogleUtilities/Environment (~> 6.7)		    - GoogleUtilities/Environment (~> 6.7)
    - GoogleUtilities/Logger (~> 6.7)		    - GoogleUtilities/Logger (~> 6.7)
 @@ -56,7 +56,7 @@ PODS:
    - GoogleUtilities/Environment (~> 6.7)		    - GoogleUtilities/Environment (~> 6.7)
    - GoogleUtilities/Logger (~> 6.7)		    - GoogleUtilities/Logger (~> 6.7)
    - nanopb (~> 1.30906.0)		    - nanopb (~> 1.30906.0)
  - FirebaseCrashlytics (4.6.1):		  - FirebaseCrashlytics (4.6.2):
    - FirebaseCore (~> 6.10)		    - FirebaseCore (~> 6.10)
    - FirebaseInstallations (~> 1.6)		    - FirebaseInstallations (~> 1.6)
    - GoogleDataTransport (~> 7.2)		    - GoogleDataTransport (~> 7.2)
 @@ -67,20 +67,20 @@ PODS:
    - GoogleUtilities/Environment (~> 6.7)		    - GoogleUtilities/Environment (~> 6.7)
    - GoogleUtilities/UserDefaults (~> 6.7)		    - GoogleUtilities/UserDefaults (~> 6.7)
    - PromisesObjC (~> 1.2)		    - PromisesObjC (~> 1.2)
  - FirebaseInstanceID (4.7.0):		  - FirebaseInstanceID (4.8.0):
    - FirebaseCore (~> 6.10)		    - FirebaseCore (~> 6.10)
    - FirebaseInstallations (~> 1.6)		    - FirebaseInstallations (~> 1.6)
    - GoogleUtilities/Environment (~> 6.7)		    - GoogleUtilities/Environment (~> 6.7)
    - GoogleUtilities/UserDefaults (~> 6.7)		    - GoogleUtilities/UserDefaults (~> 6.7)
  - FirebaseMessaging (4.7.0):		  - FirebaseMessaging (4.7.1):
    - FirebaseCore (~> 6.10)		    - FirebaseCore (~> 6.10)
    - FirebaseInstanceID (~> 4.7)		    - FirebaseInstanceID (~> 4.7)
    - GoogleUtilities/AppDelegateSwizzler (~> 6.7)		    - GoogleUtilities/AppDelegateSwizzler (~> 6.7)
    - GoogleUtilities/Environment (~> 6.7)		    - GoogleUtilities/Environment (~> 6.7)
    - GoogleUtilities/Reachability (~> 6.7)		    - GoogleUtilities/Reachability (~> 6.7)
    - GoogleUtilities/UserDefaults (~> 6.7)		    - GoogleUtilities/UserDefaults (~> 6.7)
    - Protobuf (>= 3.9.2, ~> 3.9)		    - Protobuf (>= 3.9.2, ~> 3.9)
  - FirebasePerformance (3.3.0):		  - FirebasePerformance (3.3.1):
    - FirebaseCore (~> 6.9)		    - FirebaseCore (~> 6.9)
    - FirebaseInstallations (~> 1.5)		    - FirebaseInstallations (~> 1.5)
    - FirebaseRemoteConfig (~> 4.7)		    - FirebaseRemoteConfig (~> 4.7)
 @@ -92,20 +92,20 @@ PODS:
    - GoogleUtilities/MethodSwizzler (~> 6.2)		    - GoogleUtilities/MethodSwizzler (~> 6.2)
    - GTMSessionFetcher/Core (~> 1.1)		    - GTMSessionFetcher/Core (~> 1.1)
    - Protobuf (~> 3.12)		    - Protobuf (~> 3.12)
  - FirebaseRemoteConfig (4.9.0):		  - FirebaseRemoteConfig (4.9.1):
    - FirebaseABTesting (~> 4.2)		    - FirebaseABTesting (~> 4.2)
    - FirebaseCore (~> 6.10)		    - FirebaseCore (~> 6.10)
    - FirebaseInstallations (~> 1.6)		    - FirebaseInstallations (~> 1.6)
    - GoogleUtilities/Environment (~> 6.7)		    - GoogleUtilities/Environment (~> 6.7)
    - "GoogleUtilities/NSData+zlib (~> 6.7)"		    - "GoogleUtilities/NSData+zlib (~> 6.7)"
  - GoogleAppMeasurement (6.8.3):		  - GoogleAppMeasurement (6.9.0):
    - GoogleUtilities/AppDelegateSwizzler (~> 6.7)		    - GoogleUtilities/AppDelegateSwizzler (~> 6.7)
    - GoogleUtilities/MethodSwizzler (~> 6.7)		    - GoogleUtilities/MethodSwizzler (~> 6.7)
    - GoogleUtilities/Network (~> 6.7)		    - GoogleUtilities/Network (~> 6.7)
    - "GoogleUtilities/NSData+zlib (~> 6.7)"		    - "GoogleUtilities/NSData+zlib (~> 6.7)"
    - nanopb (~> 1.30906.0)		    - nanopb (~> 1.30906.0)
  - GoogleDataTransport (7.4.0):		  - GoogleDataTransport (7.5.1):
    - nanopb (~> 1.30906.0)		    - nanopb (~> 1.30906.0)
  - GoogleToolboxForMac/Defines (2.2.2)		  - GoogleToolboxForMac/Defines (2.2.2)
  - GoogleToolboxForMac/Logger (2.2.2):		  - GoogleToolboxForMac/Logger (2.2.2):

We do have Performance monitoring included, I'm going to remove it now if it helps and let you know, I just thought I'll leave this here as well if it helps debugging this issue.

EDIT: Part of Performance monitoring is also ISASwizzler, MethodSwizzler and other libs (via screenshot) - it might be some of them as well.
ISASwizzler was refactored couple of days ago to support ARC (#5862), but I don't think this was part of 6.34 yet

Screenshot 2020-10-16 at 11 26 32

@maksymmalyhin
Copy link
Contributor

Thank you for the provided details. We will continue investigation and post updates to the thread.

@davidgrigoryan
Copy link

@maksymmalyhin Hello. We are receiving same crashes from Alamofire after updating Firebase SDK to the last version. Would you suggest to downgrade to previous version and update the app before you fix the issue?

@visumickey
Copy link
Contributor

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?

  1. Version of Alamofire used by your app.
  2. Type of network request where this crash is occurring (Eg. DataTaskWithCompletionHandler, dataTaskWithURLRequest)
  3. Any simple/sample app where we can reproduce the issue? (Even steps would do!)

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.

@Kaspik
Copy link

Kaspik commented Oct 17, 2020

I would love to provide you with all the crashes we are seeing, but Firebase console doesn't allow us to share crashes as Fabric did, nor it has a way to export them.

To answer:

  1. Latest release from July - 5.2.2 (We also use AFNetworking that we are migrating from, but we have this mixed project for months already)
  2. Not sure I can say specifically
  3. Don't have one right now, sorry!

If that helps, we also use PINRemoteImage for remote images loading, and we are seeing the crash there as well.

Here is a txt file with 4 top crashes (we are talking about thousands of crashes on 1% rollout) - always only the first important thread, not the rest of threads. I hope that helps!

crashes.txt

@tspecht
Copy link
Author

tspecht commented Oct 17, 2020

@visumickey we are also using Alamofire 5.2.2. We have also observed the same exact crash pattern but when using networking from within Kingfisher as well as using plain-old URLSession itself - not sure how likely it is that this is just a bad synergy with Alamofire specifically.

@Kaspik
Copy link

Kaspik commented Oct 17, 2020

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. :)

@mthormann-dhi
Copy link

@tspecht @paulb777 We're seeing this as well in our development CI builds on 7.0 as well as App Store version that released with 6.34.0 (pre-patch to Firebase Performance 3.3.2). We're hotfixing the App Store version to 6.34.0 post patch and will revert our dev code back from 7.0 till this is all resolved.

@visumickey
Copy link
Contributor

@mthormann-dhi Since this is happening on the development CI builds, do you have any steps to reproduce this issue? Currently, we are working on all possibilities that could lead to such a crash and having a defined set of steps could expedite the fix greatly.

Can you also provide details about the APIs you are making network request with? Eg. dataTaskWithURLRequest, [NSURLSession sessionWithDelegate] and likes.

@mthormann-dhi
Copy link

mthormann-dhi commented Oct 30, 2020

We can't get it to happen on any particular test. We run approx. 80 UI tests and it seems to trigger on different ones each time. Test order is randomized as well though. Doesn't seem to happen when we run just one or two tests though but more the whole suite.

Most of our calls are done through Alamofire and/or AFNetworking. It's a mixed Objective-C/Swift project and we haven't been able to transition to just one.

I do have a source branch that can pretty reliably duplicate things running interactively as well in Xcode. I'll see if I can fix the test order on Monday and nail it down if that helps.

@visumickey
Copy link
Contributor

@mthormann-dhi That would be greatly helpful. In the meantime, we will continue to cleanup all possible scenarios where this issue might occur.

Thanks for the information about Swift+ObjC app combined. We could add that to our mix of test cases.

Can you share the version of AlamoFire and AFNetworking you are using?

@digitalby
Copy link

I, too, started seeing random crashes like the ones described above after upgrading to version 7. Not using Alamofire though. The project is 100% Swift with SwiftUI and runs only on iOS 14+.

@ethanwa
Copy link

ethanwa commented Oct 31, 2020

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:

Screen Shot 2020-10-31 at 4 57 09 PM

@mthormann-dhi
Copy link

Alamofire 5.2.2
AFNetworking 4.0.1

Like the other comments we're seeing errors all over looks like related to KVO type stuff. Some stack traces as well.

Crashed: org.alamofire.session.rootQueue 0 libobjc.A.dylib 0x1c0f8e010 objc_retain + 16 1 Foundation 0x1ae1ea8f0 NSKeyValueWillChange + 404 2 Foundation 0x1ae1ea5b8 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 432 3 Foundation 0x1ae12711c -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 72 4 Foundation 0x1ae1e573c _NSSetLongLongValueAndNotify + 312 5 CFNetwork 0x1ad6b54c4 _CFNetworkHTTPConnectionCacheSetLimit + 150756 6 Foundation 0x1ae20e7f4 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24 7 Foundation 0x1ae101120 -[NSBlockOperation main] + 104 8 Foundation 0x1ae210bb8 __NSOPERATION_IS_INVOKING_MAIN__ + 24 9 Foundation 0x1ae100da8 -[NSOperation start] + 808 10 Foundation 0x1ae211624 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 24 11 Foundation 0x1ae2110d0 __NSOQSchedule_f + 184 12 libdispatch.dylib 0x1acb02834 _dispatch_block_async_invoke2 + 148 13 libdispatch.dylib 0x1acaf4ac8 _dispatch_client_callout + 20 14 libdispatch.dylib 0x1acafbc08 _dispatch_lane_serial_drain + 580 15 libdispatch.dylib 0x1acafc734 _dispatch_lane_invoke + 408 16 libdispatch.dylib 0x1acb06528 _dispatch_workloop_worker_thread + 708 17 libsystem_pthread.dylib 0x1f4448908 _pthread_wqthread + 276 18 libsystem_pthread.dylib 0x1f444f77c start_wqthread + 8

Crashed: com.apple.main-thread 0 CoreFoundation 0x1a563d35c CFDictionaryGetValue + 88 1 Foundation 0x1a69e9660 _NSSetLongLongValueAndNotify + 92 2 libdispatch.dylib 0x1a52f2fd0 _dispatch_call_block_and_release + 32 3 libdispatch.dylib 0x1a52f4ac8 _dispatch_client_callout + 20 4 libdispatch.dylib 0x1a530204c _dispatch_main_queue_callback_4CF + 836 5 CoreFoundation 0x1a56731e4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 6 CoreFoundation 0x1a566d3b4 __CFRunLoopRun + 2508 7 CoreFoundation 0x1a566c4bc CFRunLoopRunSpecific + 600 8 GraphicsServices 0x1bc17e820 GSEventRunModal + 164 9 UIKitCore 0x1a8019164 -[UIApplication _run] + 1072 10 UIKitCore 0x1a801e840 UIApplicationMain + 168 11 Dice 0x104367690 main + 9 (main.swift:9) 12 libdyld.dylib 0x1a5333e40 start + 4

Crashed: com.apple.NSURLSession-work 0 libobjc.A.dylib 0x1b6761dc0 objc_release + 16 1 Foundation 0x1b6df9a24 NSKeyValuePopPendingNotificationLocal + 152 2 Foundation 0x1b6df9944 NSKeyValueDidChange + 372 3 Foundation 0x1b6df9398 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 632 4 Foundation 0x1b6d42f60 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 72 5 Foundation 0x1b6df4d88 _NSSetLongLongValueAndNotify + 300 6 CFNetwork 0x1b9cb95ec CFNetServiceBrowserSearchForServices + 1784 7 CFNetwork 0x1b9edba8c __CFTubeSetTubeTypeNotifier + 42716 8 libdispatch.dylib 0x1b66d2134 _dispatch_call_block_and_release + 32 9 libdispatch.dylib 0x1b66d35ac _dispatch_client_callout + 20 10 libdispatch.dylib 0x1b66d9a64 _dispatch_lane_serial_drain + 568 11 libdispatch.dylib 0x1b66da4cc _dispatch_lane_invoke + 452 12 libdispatch.dylib 0x1b66e3a5c _dispatch_workloop_worker_thread + 584 13 libsystem_pthread.dylib 0x1b6739718 _pthread_wqthread + 276 14 libsystem_pthread.dylib 0x1b673f9c8 start_wqthread + 8

Crashed: com.sift.SFUploader 0 libobjc.A.dylib 0x1b7c02160 objc_release + 16 1 Foundation 0x1a4deed18 NSKeyValuePopPendingNotificationLocal + 152 2 Foundation 0x1a4deec38 NSKeyValueDidChange + 360 3 Foundation 0x1a4dee690 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 648 4 Foundation 0x1a4d2b11c -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 72 5 Foundation 0x1a4de973c _NSSetLongLongValueAndNotify + 312 6 CFNetwork 0x1a433f3b0 __CFTubeSetTubeTypeNotifier + 57112 7 AFNetworking 0x10095d8a8 -[_AFURLSessionTaskSwizzling af_resume] + 430 (AFURLSessionManager.m:430) 8 Sift 0x10113b2d8 __24-[SiftUploader doUpload]_block_invoke_2 + 192 (SiftUploader.m:192) 9 libdispatch.dylib 0x1a36f2fd0 _dispatch_call_block_and_release + 32 10 libdispatch.dylib 0x1a36f4ac8 _dispatch_client_callout + 20 11 libdispatch.dylib 0x1a36fbc08 _dispatch_lane_serial_drain + 580 12 libdispatch.dylib 0x1a36fc734 _dispatch_lane_invoke + 408 13 libdispatch.dylib 0x1a3706528 _dispatch_workloop_worker_thread + 708 14 libsystem_pthread.dylib 0x1eb9e7908 _pthread_wqthread + 276 15 libsystem_pthread.dylib 0x1eb9ee77c start_wqthread + 8

@theofficejackpot
Copy link

theofficejackpot commented Nov 2, 2020

I'll chime in here as well.
I have finally found a scenario in my app that can crash every time (Crashed: org.alamofire.session.rootQueue). I had Alamofire 4.8 (legacy) and thought that was the culprit because it was crashing on an Alamofire thread, so I spent a LOT of time over this weekend updating to Alamofire 5.3. Still crashed.
Then I came across this thread.

I can confirm, zero crashes after downgrading to 6.34. See my pod install downgrade log:

Analyzing dependencies
Downloading dependencies
Installing Firebase 6.34.0 (was 7.0.0)
Installing FirebaseABTesting 4.2.0 (was 7.0.0)
Installing FirebaseAnalytics 6.9.0 (was 7.0.0)
Installing FirebaseAuth 6.9.2 (was 7.0.0)
Installing FirebaseCore 6.10.4 (was 7.0.0)
Installing FirebaseCoreDiagnostics 1.7.0 (was 7.0.0)
Installing FirebaseCrashlytics 4.6.2 (was 7.0.0)
Installing FirebaseInstallations 1.7.0 (was 7.0.0)
Installing FirebaseInstanceID 4.8.0 (was 7.0.0)
Installing FirebaseMessaging 4.7.1 (was 7.0.0)
Installing FirebasePerformance 3.3.2 (was 7.0.0)
Installing FirebaseRemoteConfig 4.9.1 (was 7.0.0)
Installing Google-Mobile-Ads-SDK 7.67.0 (was 7.67.1)
Installing GoogleAppMeasurement 6.9.0 (was 7.0.0)
Installing GoogleDataTransport 7.5.1 (was 8.0.0)
Installing GoogleUtilities 6.7.2 (was 7.0.0)
Installing nanopb 1.30906.0 (was 2.30906.0)
Generating Pods project
Integrating client project

I was able to do this by setting this in my pod file:
pod 'Firebase/Core', '~> 6.33'

Then running these commands:
rm -rf Podfile.lock Pods/;pod install --repo-update

Then cleaning build folder in Xcode, letting it index, then building.

@visumickey
Copy link
Contributor

visumickey commented Nov 2, 2020

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, pinterest/PINRemoteImage#390

To mitigate this, we will remove the KVO based implementation with an alternate mechanism to stop these crashes from occurring.

@petrykDima
Copy link

@maksymmalyhin which solution is best right now?
downgrading to 6.34 and waiting for new Firebase release?

@petrykDima
Copy link

petrykDima commented Nov 3, 2020

@visumickey maybe you can recommend something in current situation. I have about 800 crashes after release new version in one day =)

#6734 (comment)

@paulb777
Copy link
Member

paulb777 commented Nov 3, 2020

Two workarounds until the crash is addressed in Firebase 7.x:

  • Downgrade to 6.34
  • Remove FirebasePerformance from the app

@petrykDima
Copy link

@paulb777 thanks

@tspecht
Copy link
Author

tspecht commented Nov 3, 2020

@petrykDima we have removed everything from the Firebase suite that was not 💯 necessary and will not be back any time soon ...

@visumickey
Copy link
Contributor

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.

@tspecht
Copy link
Author

tspecht commented Nov 4, 2020

@visumickey was a new Firebase version released for this in general? Just to be clear, we stopped using Firebase/Performance a couple of weeks ago when these issues first started happening, but even updating the remaining FIrebase pods to 7.0.0 still had those issues. Here's the list of what we currently have installed on 7.0.0

  pod "Firebase/Crashlytics", FirebaseVersion
  pod "Firebase/RemoteConfig", FirebaseVersion
  pod "Firebase/Analytics", FirebaseVersion
  pod "Firebase/Auth", FirebaseVersion
  pod "Firebase/AppDistribution", FirebaseVersion

@visumickey
Copy link
Contributor

@tspecht This emergency fix has only Firebase performance in it. You can set only the Firebase performance SDK's version to 7.0.1 to get past the issue. Other pods can continue to use the same version of Firebase you have.

@visumickey
Copy link
Contributor

That is surprising. Based on the stack trace provided above, these issues were arising out of Firebase performance. If you are seeing this still, quite likely it is because of your other dependencies (most likely non-Firebase dependencies).

@paulb777
Copy link
Member

paulb777 commented Nov 4, 2020

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.

@tspecht
Copy link
Author

tspecht commented Nov 4, 2020

@paulb777 was this already pushed up to the Cocoapods remote?

$ pod install --repo-update

[!] CocoaPods could not find compatible versions for pod "Firebase/Performance":
  In Podfile:
    Firebase/Performance (= 7.0.1)

None of your spec sources contain a spec satisfying the dependency: `Firebase/Performance (= 7.0.1)`.

You have either:
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

@paulb777
Copy link
Member

paulb777 commented Nov 4, 2020

@tspecht Yes. The Firebase pod did not change versions. Only the FirebasePerformance pod. So either remove the version specifier or remove the slash - FirebasePerformance instead of Firebase/Performance.

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