Firebase-ios-sdk: [RemoteConfig] Crash if initializing after app start

Created on 12 Jul 2019  路  35Comments  路  Source: firebase/firebase-ios-sdk

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.2.1
  • Firebase SDK version: 6.4.0
  • Firebase Component: RemoteConfig
  • Component version: 4.2.0

[REQUIRED] Step 3: Describe the problem

Stack trace:

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000fca8c6b30
-[RCNConfigExperiment initWithDBManager:]

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x180d87530 objc_msgSend + 16
1  Runner                         0x10284c130 -[RCNConfigExperiment initWithDBManager:] + 4376871216
2  Runner                         0x102841920 -[FIRRemoteConfig initWithAppName:FIROptions:namespace:DBManager:configContent:] + 4376828192
3  Runner                         0x1028450e8 -[FIRRemoteConfigComponent remoteConfigForNamespace:] + 4376842472
4  Runner                         0x102841660 +[FIRRemoteConfig remoteConfigWithFIRNamespace:app:] + 4376827488
5  Runner                         0x102841720 +[FIRRemoteConfig remoteConfig] + 4376827680
6  Runner                         0x102905bec -[FirebaseRemoteConfigPlugin handleMethodCall:result:] + 39 (FirebaseRemoteConfigPlugin.m:39)
7  Flutter                        0x102f55ba8 (Missing)
8  Flutter                        0x102ef96a4 (Missing)
9  Flutter                        0x102f48ad0 (Missing)
10 Flutter                        0x102f04534 (Missing)
11 Flutter                        0x102f07cc8 (Missing)
12 CoreFoundation                 0x181b27650 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
13 CoreFoundation                 0x181b27380 __CFRunLoopDoTimer + 864
14 CoreFoundation                 0x181b26bb4 __CFRunLoopDoTimers + 248
15 CoreFoundation                 0x181b21b04 __CFRunLoopRun + 1844
16 CoreFoundation                 0x181b210b0 CFRunLoopRunSpecific + 436
17 GraphicsServices               0x183d2179c GSEventRunModal + 104
18 UIKitCore                      0x1ae38d978 UIApplicationMain + 212
19 Runner                         0x102601d48 main + 5 (AppDelegate.swift:5)
20 libdyld.dylib                  0x1815e68e0 start + 4

Steps to reproduce:

After upgrading Firebase dependencies from 6.3.0 to 6.4.0 and RemoteConfig from 4.1.0 to 4.2.0 we are getting crashes directly on app start. If the crash happen the next app starts are working. After some time (~1 hour) the crash happen again. We are using Firebase in a Flutter project.

Relevant Code:

Entry point: https://github.com/flutter/plugins/blob/master/packages/firebase_remote_config/ios/Classes/FirebaseRemoteConfigPlugin.m#L39

performance remoteconfig

Most helpful comment

@paulb777 I can confirm the fix. Thanks for your quick help!

All 35 comments

Hi @tecbot - looking into this right away. Some quick questions as I start investigating:

  • Does this happen on any specific iOS version, or all of them?
  • Does it happen on both device and simulator?
  • Can you enable Zombies in your application and see where it's failing? It looks like it's trying to access an already deallocated instance of something (based on KERN_INVALID_ADDRESS)

Thanks, and sorry for the troubles!

I haven't been able to reproduce this using a non-Flutter app, looking at setting up Flutter in order to try it out. If you have a plain reproduction (without GoogleService-Info.plist) you could share, it'd be very helpful 馃檪

I have 2 crashes in same class in my apps :
first one
RCNConfigExperiment initWithDBManager

Fatal Exception: NSInvalidArgumentException-[__NSCFString setTimeZone:]: unrecognized selector sent to instance 0x2800f36f0

second one
-[RCNConfigExperiment initWithDBManager:]
Crashed: com.google.perf.FPREventsQueue
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x7265567733237863

com.test.app_issue_crash_f34c5ae3e6924654a8390f7336a46fd3_DNE_0_v2.txt
com.test.app_issue_crash_ed38c08906b044109d994521a23efeb5_DNE_0_v2.txt

@mouness2020 Thanks for the additional detail.

@ryanwilson, @dmandar I suspect a thread safety issue with the static variable assigned the NSDateFormatter. One thread is creating another instance while another thread is sending the setTimeZone: message.

Thanks folks for the extra information - I have a pending fix internally at cl/258032937.

We still haven't been able to reproduce this, so if anyone can provide reproduction steps so we can verify the fix works properly, it would be greatly appreciated.

This crash should only happen if you are using FirePerf or if you have multiple active instances of RC (not common) in your app. Please let us know if it s not the case for you.

Yes that's true i'm using FirePef .. also i have two firebase projects
one for live api and second one for test api but one of them works at time

let firebasePlistFileName: String = typeURL != "api" ? "GoogleService-Info-test" : "GoogleService-Info"

        if let path = Bundle.main.path(forResource: firebasePlistFileName, ofType: "plist"),let firbaseOptions = FirebaseOptions(contentsOfFile: path){

            firbaseOptions.deepLinkURLScheme = self.customURLScheme

            FirebaseOptions.defaultOptions()?.deepLinkURLScheme =  self.customURLScheme
            FirebaseConfiguration.shared.setLoggerLevel(.min)
            FirebaseApp.configure(options: firbaseOptions)


        }

        Analytics.setAnalyticsCollectionEnabled(true)
        Performance.sharedInstance().isInstrumentationEnabled = true
        Performance.sharedInstance().isDataCollectionEnabled = true

We also experience this crash, we have a single instance of RC and we do use Firebase Performance. The crash happens half of the times on a clean install. Removing Firebase Performance fixes this issue. In the meantime we downgraded to 6.3.0

I also have this issue. It happens on fresh installs and old ones.

My configuration on AppDelegate is

// Firebase

#if DEVELOP
    let firConfigFilename = "GoogleService-Info-Dev"
#else
    let firConfigFilename = "GoogleService-Info"
#endif

let firConfigPath = Bundle.main.path(forResource: firConfigFilename, ofType: "plist")!

FirebaseApp.configure(options: FirebaseOptions(contentsOfFile: firConfigPath)!)
FirebaseConfiguration.shared.setLoggerLevel(.min)

// Remote Config

let remoteConfig = RemoteConfig.remoteConfig()
remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")
remoteConfig.fetchAndActivate()

@igiazlas thanks for the report. Is reproducible for you on a local test device? If so, what iOS version and what device / simulator are you using?

We have what we believe is a fix going into the next release that's being packaged and tested shortly, hopefully we can find a reliable repro to validate this issue goes away.

I can reproduce it on an iPhone X running 12.3.1, on a 5s running 12.4 beta but not on a 6s running 11.4.1 (see edit). Also in all the 12.3.1 simulators I checked. It is consistent if I leave the last 3 lines in AppDelegate. If I remove them, and don't put them anywhere else, it does not crash, at least not for the first 20-30 seconds that I let it run.

Edit: Before your last comment I downgraded to 6.3.0 and run the app on my devices with no problems. I upgraded again to make recheck the 11.4.1 6s and it didn't crash. The weird thing is that after I build for the other devices they also do not crash anymore. When I delete the app and rebuild it it starts crashing again. So on some old installs it does not crash but it does crash consistently on fresh installs (Delete, Build, Install) on all devices, including the 6s with 11.4.1.

Edit 2: I have about 50 keys on my default configuration about 70 in total, including many that I do not use as they are used by the Android app

Edit 3: It is not that consistent after all. In some cases, removing and reinstalling the app does not cause a crash.

Hi there,
Same problem for me on my device iPhone X 12.3.1 after a pod update to 6.4.0.
I use Firebase with RemoteConfig and Performance and I have the same setup than @igiazlas except that I set my defaults from a dictionary and call fetch:withExpirationDuration and after activate.

As said before @b-onc, I suspect a conflict with Performance because I don't have the same problem after a migration of firebase on Carthage without performance.

I also use Firebase Performance as @KevinLaRosa. This is the Firebase values I have on the Podfile.lock

- Firebase/Analytics (6.4.0):
  - Firebase/Core
- Firebase/Auth (6.4.0):
  - Firebase/CoreOnly
  - FirebaseAuth (~> 6.2.0)
- Firebase/Core (6.4.0):
  - Firebase/CoreOnly
  - FirebaseAnalytics (= 6.0.3)
- Firebase/CoreOnly (6.4.0):
  - FirebaseCore (= 6.0.4)
- Firebase/Performance (6.4.0):
  - Firebase/CoreOnly
  - FirebasePerformance (~> 3.1.1)
- Firebase/RemoteConfig (6.4.0):
  - Firebase/CoreOnly
  - FirebaseRemoteConfig (~> 4.2.0)
- FirebaseABTesting (3.0.0):
  - FirebaseCore (~> 6.0)
  - Protobuf (~> 3.5)
- FirebaseAnalytics (6.0.3):
  - FirebaseCore (~> 6.0)
  - FirebaseInstanceID (~> 4.2)
  - GoogleAppMeasurement (= 6.0.3)
  - GoogleUtilities/AppDelegateSwizzler (~> 6.0)
  - GoogleUtilities/MethodSwizzler (~> 6.0)
  - GoogleUtilities/Network (~> 6.0)
  - "GoogleUtilities/NSData+zlib (~> 6.0)"
  - nanopb (~> 0.3)
- FirebaseAuth (6.2.0):
  - FirebaseAuthInterop (~> 1.0)
  - FirebaseCore (~> 6.0)
  - GoogleUtilities/AppDelegateSwizzler (~> 6.2)
  - GoogleUtilities/Environment (~> 6.2)
  - GTMSessionFetcher/Core (~> 1.1)
- FirebaseAuthInterop (1.0.0)
- FirebaseCore (6.0.4):
  - GoogleUtilities/Environment (~> 6.0)
  - GoogleUtilities/Logger (~> 6.0)
- FirebaseInstanceID (4.2.1):
  - FirebaseCore (~> 6.0)
  - GoogleUtilities/Environment (~> 6.0)
  - GoogleUtilities/UserDefaults (~> 6.0)
- FirebasePerformance (3.1.1):
  - FirebaseCore (~> 6.0)
  - FirebaseInstanceID (~> 4.2)
  - FirebaseRemoteConfig (~> 4.2)
  - GoogleToolboxForMac/Logger (~> 2.1)
  - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
  - GoogleUtilities/Environment (~> 6.0)
  - GoogleUtilities/ISASwizzler (~> 6.0)
  - GoogleUtilities/MethodSwizzler (~> 6.0)
  - GTMSessionFetcher/Core (~> 1.1)
  - Protobuf (~> 3.5)
- FirebaseRemoteConfig (4.2.0):
  - FirebaseABTesting (~> 3.0)
  - FirebaseCore (~> 6.0)
  - FirebaseInstanceID (~> 4.2)
  - GoogleUtilities/Environment (~> 6.0)
  - "GoogleUtilities/NSData+zlib (~> 6.0)"
  - Protobuf (~> 3.5)
- FirebaseUI/Auth (8.0.4):
  - Firebase/Auth (~> 6.0)
  - GoogleUtilities/UserDefaults
- FirebaseUI/Facebook (8.0.4):
  - FBSDKLoginKit (~> 5.0)
  - FirebaseUI/Auth
- FirebaseUI/Google (8.0.4):
  - FirebaseUI/Auth
  - GoogleSignIn (~> 4.0)

@igiazlas can you verify which simulator versions you're using? As far as I'm aware there are no 12.3.1 simulators, only 12.2.

I have half the time the crash on simulator 12.2.

2019-07-17 16:37:14.252544+0200 xxx [8058:366577] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSMallocBlock__ setLocale:]: unrecognized selector sent to instance 0x60000162e3a0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000011999c1bb __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x0000000118f3a735 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001199baf44 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x00000001199a0ed6 ___forwarding___ + 1446
    4   CoreFoundation                      0x00000001199a2da8 _CF_forwarding_prep_0 + 120
    5   xxxKit                       0x00000001188e3776 -[RCNConfigExperiment initWithDBManager:] + 379
    6   xxxKit                        0x00000001188d8bf2 -[FIRRemoteConfig initWithAppName:FIROptions:namespace:DBManager:configContent:] + 440
    7   xxxKit                        0x00000001188dc497 -[FIRRemoteConfigComponent remoteConfigForNamespace:] + 668
    8   xxx                      0x000000010eba6aa0 +[FIRRemoteConfig remoteConfigWithFIRNamespace:app:] + 133
    9   xxx                      0x000000010eb1da51 __38+[FPRRemoteConfigFlags sharedInstance]_block_invoke + 76
    10  libdispatch.dylib                   0x000000011b63f602 _dispatch_client_callout + 8
    11  libdispatch.dylib                   0x000000011b6410c4 _dispatch_once_callout + 66
    12  xxx                      0x000000010eb1da02 +[FPRRemoteConfigFlags sharedInstance] + 45
    13  xxx                      0x000000010eb1c896 -[FPRConfigurations setupRemoteConfigFlags] + 135
    14  xxx                     0x000000010eb1c7d7 -[FPRConfigurations update] + 125
    15  xxx                      0x000000010eb1fa15 __42-[FPRClient startWithConfiguration:error:]_block_invoke + 802
    16  libdispatch.dylib                   0x000000011b63e595 _dispatch_call_block_and_release + 12
    17  libdispatch.dylib                   0x000000011b63f602 _dispatch_client_callout + 8
    18  libdispatch.dylib                   0x000000011b646cad _dispatch_lane_serial_drain + 1209
    19  libdispatch.dylib                   0x000000011b647784 _dispatch_lane_invoke + 428
    20  libdispatch.dylib                   0x000000011b65189a _dispatch_workloop_worker_thread + 733
    21  libsystem_pthread.dylib             0x000000011ba2d611 _pthread_wqthread + 421
    22  libsystem_pthread.dylib             0x000000011ba2d3fd start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

@ryanwilson you are right, I meant to say the latest simulators which are 12.2

Based on all your input, we have made a fix for a race that occurs if Perf and RC SDK are both included, which should be out soon. @igiazlas can you also confirm you are also using FirePerf? If not, please confirm if you have the same stack trace.

@dmandar yes, I also use FirePerf. I've posted my Podfile.lock above.

My app also crashes a lot because of this
Screen Shot 2019-07-18 at 12 41 35 PM
Screen Shot 2019-07-18 at 12 43 45 PM
Screen Shot 2019-07-18 at 12 44 06 PM

Also experiencing the crash at times.
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000007b9678940
-[RCNConfigExperiment initWithDBManager:]

Not present in 6.3.0

Firebase 6.5.0 just released with a fix. We were never able to reproduce the issue internally so would appreciate confirmation from those who saw the issue.

@paulb777 I can confirm the fix. Thanks for your quick help!

I was getting the similar crashes on app start during the UITests running on CI using Firebase 6.3. After upgrading to 6.5 today, and running couple of times I can no longer see this crash on startup. Thanks

Same crash happening on Firebase (6.7.0) and FirebaseCore (6.2.1).

@ppamorim can you please update to the latest version Firebase (6.8.1) and let us know if you're still seeing the crash?

@ryanwilson I will, thanks.

I am seeing this issue with Firebase (6.8.1)
Crashed: com.google.GoogleConfigService.FIRRemoteConfig 0 libdispatch.dylib 0x182831bac <redacted> + 452 1 libdispatch.dylib 0x182831724 <redacted> + 144 2 SimpliSafe 0x100e5947c -[FIRRemoteConfig configValueForKey:namespace:] + 378 (FIRRemoteConfig.m:378) 3 SimpliSafe 0x100df8c34 -[FPRRemoteConfigFlags sessionSamplingRate] + 4343942196 4 SimpliSafe 0x100df8294 -[FPRConfigurations sessionsSamplingPercentage] + 4343939732 5 SimpliSafe 0x100df3188 -[FPRSessionManager isGaugeCollectionEnabledForSessionId:] + 4343918984 6 SimpliSafe 0x100df3038 -[FPRSessionManager updateSessionId:] + 4343918648 7 SimpliSafe 0x100df2da0 -[FPRSessionManager initWithNotificationCenter:] + 4343917984 8 SimpliSafe 0x100df2cfc __35+[FPRSessionManager sharedInstance]_block_invoke + 4343917820 9 libdispatch.dylib 0x182825088 <redacted> + 20 10 libdispatch.dylib 0x182826770 <redacted> + 32 11 SimpliSafe 0x100df2ca0 +[FPRSessionManager sharedInstance] + 4343917728 12 SimpliSafe 0x100e03700 -[FPRNetworkTrace start] + 4343985920 13 SimpliSafe 0x100e0a730 __InstrumentDataTaskWithRequestCompletionHandler_block_invoke + 4344014640 14 SimpliSafe 0x100e0a6ac __InstrumentDataTaskWithRequestCompletionHandler_block_invoke + 4344014508 15 SimpliSafe 0x100de2f40 -[FIRInstanceIDCheckinService checkinWithExistingCheckin:completion:] + 189 (FIRInstanceIDCheckinService.m:189) 16 SimpliSafe 0x100de06bc -[FIRInstanceIDAuthService fetchCheckinInfoWithHandler:] + 188 (FIRInstanceIDAuthService.m:188) 17 SimpliSafe 0x100dd9d28 -[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler:] + 368 (FIRInstanceID.m:368) 18 SimpliSafe 0x100e67528 -[RCNConfigFetch refreshInstanceIDTokenAndFetchCheckInInfoWithCompletionHandler:] + 230 (RCNFetch.m:230) 19 SimpliSafe 0x100e6718c __74-[RCNConfigFetch fetchAllConfigsWithExpirationDuration:completionHandler:]_block_invoke + 190 (RCNFetch.m:190) 20 libdispatch.dylib 0x182823c2c <redacted> + 32 21 libdispatch.dylib 0x182825088 <redacted> + 20 22 libdispatch.dylib 0x18282b500 <redacted> + 568 23 libdispatch.dylib 0x18282bf2c <redacted> + 368 24 libdispatch.dylib 0x182834f9c <redacted> + 580 25 libsystem_pthread.dylib 0x18288aaa4 _pthread_wqthread + 280 26 libsystem_pthread.dylib 0x182890c7c start_wqthread + 8

@dmandar looks like a regression, can you investigate?

@garypez This looks like #3842. Please follow the steps listed there to make sure you have a clean build.

I'll close this one. Please follow up in #3842 if you're unable to resolve.

@paulb777 @ryanwilson hi guys. I am trying to link performance sdk manually today and getting these same crashes on app launch. Will follow #3842 , but I am running iOS 12 still.
Details:
iOS ObjectiveC (+Swift) project running on Xcode
phone = iPhone XR
OS = 12.4.1

Objective:

install Firebase for an existing project without Cocoapods . Need manual install of frameworks.
need to install analytics, Crashlytics and performance.

repro steps:

manually installed Analytics package
run program with no issues
manually install performance package
crash upon launch with below log

crash log :

NSInvalidArgumentException, reason: +[FIRRemoteConfig remoteConfigWithFIRNamespace:app:]: unrecognized selector sent to class 0x105b47d98`
**First throw call stack:

what could be the problem?

@valerianaGit please make sure you copy all of the frameworks from the Performance folder in the zip file. FirebaseRemoteConfig.framework is part of the Performance folder and is a required dependency of Performance.

@ryanwilson thanks so much for the response.

I did copy the entire folder (manual install, no pods) and (after clearing derived data, clean build and restarting my machine twice) I still get the above crash.

It crashes here in AppDelegate in didFinishLaunchingWithOptions

I followed the steps in getting started with Performance.

Is there anything else we might be missing to initialize or anything?

@valerianaGit can you open a new issue with your full stack trace and exception message (and ideally a sample project)? Your issue looks like a different crash than the parent.

Was this page helpful?
0 / 5 - 0 ratings