Skip to content

ThreadSanitizer detects data race when initializing FirebaseApp instance #1293

Closed
@pot8os

Description

@pot8os
  • Xcode version: 9.3.1
  • Firebase SDK version: 5.0.1
  • Firebase Component: Probably Analytics has an issue, I guess.

Hello,

After I upgraded Firebase components to 5.0.1 from 4.13.0, my app stops and the thread sanitizer shows the following stack trace while I'm running on the Xcode.

==================
WARNING: ThreadSanitizer: data race (pid=5024)
  Read of size 1 at 0x00010c745a81 by main thread (mutexes: write M821):
    #0 FIRLogBasic <null> (MyApp:x86_64+0x100467a76)
    #1 -[FIRInstanceIDLogger logFuncDebug:messageCode:msg:] <null> (MyApp:x86_64+0x1004a11d7)
    #2 +[FIRApp configureDefaultAppWithOptions:sendingNotifications:] <null> (MyApp:x86_64+0x10045a133)
    #3 +[FIRApp configureWithOptions:] <null> (MyApp:x86_64+0x100459c53)
    #4 _T07MyApp11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tF AppDelegate.swift:109 (MyApp:x86_64+0x10005568b)
    #5 _T07MyApp11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tFTo AppDelegate.swift (MyApp:x86_64+0x100055bba)
    #6 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] <null> (UIKit:x86_64+0x2175a)
    #7 start <null> (libdyld.dylib:x86_64+0x1954)

  Previous write of size 1 at 0x00010c745a81 by thread T12:
    #0 __FIRSetAnalyticsDebugMode_block_invoke <null> (MyApp:x86_64+0x100466dfc)
    #1 __tsan::invoke_and_release_block(void*) <null> (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x622bb)
    #2 _dispatch_client_callout <null> (libdispatch.dylib:x86_64+0x3847)

  Location is global 'sFIRAnalyticsDebugMode' at 0x00010c745a81 (MyApp+0x0001009a6a81)

  Mutex M821 (0x7b1800005418) created at:
    #0 pthread_mutex_lock <null> (libclang_rt.tsan_iossim_dynamic.dylib:x86_64+0x35b2e)
    #1 recursive_mutex_tt<false>::lock() <null> (libobjc.A.dylib:x86_64+0xf81c)
    #2 start <null> (libdyld.dylib:x86_64+0x1954)

  Thread T12 (tid=2580300, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: data race (MyApp:x86_64+0x100467a76) in FIRLogBasic
==================

I'm sure it doesn't exist when I use 4.13.0.

Steps to reproduce:

In my AppDelegate.swift, it initializes FirebaseApp like this. I think it's very normal.

// Firebase Debug
guard
  let filePath = Bundle.main.path(forResource: "GoogleService-Info-Debug", ofType: "plist"),
  let options = FirebaseOptions(contentsOfFile: filePath) 
  else { fatalError() }
FirebaseApp.configure(options: options) // Breakpoint stops here

I'm using the following components;

  • Firebase 5.0.1
  • FirebaseABTesting 2.0.0
  • FirebaseAnalytics 5.0.0
  • FirebaseCore 5.0.1
  • FirebaseInstanceID 3.0.0
  • FirebaseMessaging 3.0.0
  • FirebaseRemoteConfig 3.0.0

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions