firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.55k stars 1.45k forks source link

Thread Sanitizer: Data race in `-[FPRNetworkTrace responseSize]` #13581

Open jshier opened 1 week ago

jshier commented 1 week ago

Description

==================
WARNING: ThreadSanitizer: data race (pid=61556)
  Read of size 8 at 0x000115988740 by thread T78:
    #0 -[FPRNetworkTrace responseSize] <null> (FirebasePerformance:arm64+0x2e754)
    #1 FPRGetNetworkRequestMetric <null> (FirebasePerformance:arm64+0x27bf8)
    #2 __29-[FPRClient logNetworkTrace:]_block_invoke <null> (FirebasePerformance:arm64+0x114d4)
    #3 __wrap_dispatch_group_async_block_invoke <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x79210)
    #4 _dispatch_client_callout <null> (libdispatch.dylib:arm64+0x5738)

  Previous write of size 8 at 0x000115988740 by thread T68:
    #0 -[FPRNetworkTrace setResponseSize:] <null> (FirebasePerformance:arm64+0x2e7cc)
    #1 -[FPRNetworkTrace didReceiveFileURL:] <null> (FirebasePerformance:arm64+0x2c8ec)
    #2 __InstrumentDownloadTaskWithRequestCompletionHandler_block_invoke_2 <null> (FirebasePerformance:arm64+0x3ffdc)
    #3 __InstrumentDownloadTaskWithRequestCompletionHandler_block_invoke_2 <null> (FirebasePerformance:arm64+0x40090)
    #4 <null> <null> (CFNetwork:arm64+0x6a24)
    #5 _dispatch_client_callout <null> (libdispatch.dylib:arm64+0x5738)

  Location is heap block of size 112 at 0x000115988720 allocated by main thread:
    #0 calloc <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x4fc30)
    #1 _malloc_type_calloc_outlined <null> (libsystem_malloc.dylib:arm64+0xf488)
    #2 __InstrumentDownloadTaskWithRequestCompletionHandler_block_invoke <null> (FirebasePerformance:arm64+0x3fba4)
    #3 static PSPDFKit.URLDataProvider.(fetchFile in _3A67E306E4997D690E314311BCC00272)(url: Foundation.URL, targetURL: Foundation.URL, session: __C.NSURLSession, completion: (Swift.Result<Foundation.URL, Swift.Error>) -> ()) -> __C.NSURLSessionDownloadTask <null> (PSPDFKit:arm64+0x41320)
    #4 __C.PSPDFDocument.__allocating_init(url: Foundation.URL) -> __C.PSPDFDocument <null> (myVW Debug:arm64+0x100d0310c)
    #5 myVW.ManualPDFViewerViewController.viewDidLoad() -> () <null> (myVW Debug:arm64+0x100d02a38)
    #6 @objc myVW.ManualPDFViewerViewController.viewDidLoad() -> () <null> (myVW Debug:arm64+0x100d03c18)
    #7 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] <null> (UIKitCore:arm64+0x4b4e54)
    #8 <null> <null> (dyld:arm64+0x1540)

  Thread T78 (tid=693829, running) is a GCD worker thread

  Thread T68 (tid=692712, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: data race (/Users/user/Library/Developer/CoreSimulator/Devices/356CD6B3-E48F-4C77-BB33-E990B5AFDC4E/data/Containers/Bundle/Application/78AFF7C4-5719-4FD6-A628-724F3E33423D/myVW Debug.app/Frameworks/FirebasePerformance.framework/FirebasePerformance:arm64+0x2e754) in -[FPRNetworkTrace responseSize]+0x40

Reproducing the issue

Difficult, as it's a threading issue, but it looks like a straightforward set / get issue, so FPRNetworkTrace likely needs a safety pass.

Firebase SDK Version

11.1

Xcode Version

15.4

Installation Method

CocoaPods

Firebase Product(s)

Performance

Targeted Platforms

iOS

Relevant Log Output

None.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml PODS: - AEPAnalytics (5.0.2): - AEPCore (< 6.0.0, >= 5.1.0) - AEPCore (5.2.0): - AEPRulesEngine (< 6.0.0, >= 5.0.0) - AEPServices (< 6.0.0, >= 5.2.0) - AEPEdge (5.0.2): - AEPCore (< 6.0.0, >= 5.1.0) - AEPEdgeIdentity (< 6.0.0, >= 5.0.0) - AEPEdgeIdentity (5.0.0): - AEPCore (< 6.0.0, >= 5.0.0) - AEPIdentity (5.2.0): - AEPCore (< 6.0.0, >= 5.2.0) - AEPLifecycle (5.2.0): - AEPCore (< 6.0.0, >= 5.2.0) - AEPRulesEngine (5.0.0) - AEPServices (5.2.0) - Alamofire (5.9.1) - Firebase/AnalyticsWithoutAdIdSupport (11.1.0): - Firebase/CoreOnly - FirebaseAnalytics/WithoutAdIdSupport (~> 11.1.0) - Firebase/CoreOnly (11.1.0): - FirebaseCore (= 11.1.0) - Firebase/Crashlytics (11.1.0): - Firebase/CoreOnly - FirebaseCrashlytics (~> 11.1.0) - Firebase/DynamicLinks (11.1.0): - Firebase/CoreOnly - FirebaseDynamicLinks (~> 11.1.0) - Firebase/Performance (11.1.0): - Firebase/CoreOnly - FirebasePerformance (~> 11.1.0) - FirebaseABTesting (11.1.0): - FirebaseCore (~> 11.0) - FirebaseAnalytics/WithoutAdIdSupport (11.1.0): - FirebaseCore (~> 11.0) - FirebaseInstallations (~> 11.0) - GoogleAppMeasurement/WithoutAdIdSupport (= 11.1.0) - GoogleUtilities/AppDelegateSwizzler (~> 8.0) - GoogleUtilities/MethodSwizzler (~> 8.0) - GoogleUtilities/Network (~> 8.0) - "GoogleUtilities/NSData+zlib (~> 8.0)" - nanopb (~> 3.30910.0) - FirebaseCore (11.1.0): - FirebaseCoreInternal (~> 11.0) - GoogleUtilities/Environment (~> 8.0) - GoogleUtilities/Logger (~> 8.0) - FirebaseCoreExtension (11.1.0): - FirebaseCore (~> 11.0) - FirebaseCoreInternal (11.1.0): - "GoogleUtilities/NSData+zlib (~> 8.0)" - FirebaseCrashlytics (11.1.0): - FirebaseCore (~> 11.0) - FirebaseInstallations (~> 11.0) - FirebaseRemoteConfigInterop (~> 11.0) - FirebaseSessions (~> 11.0) - GoogleDataTransport (~> 10.0) - GoogleUtilities/Environment (~> 8.0) - nanopb (~> 3.30910.0) - PromisesObjC (~> 2.4) - FirebaseDynamicLinks (11.1.0): - FirebaseCore (~> 11.0) - FirebaseInstallations (11.1.0): - FirebaseCore (~> 11.0) - GoogleUtilities/Environment (~> 8.0) - GoogleUtilities/UserDefaults (~> 8.0) - PromisesObjC (~> 2.4) - FirebasePerformance (11.1.0): - FirebaseCore (~> 11.0) - FirebaseInstallations (~> 11.0) - FirebaseRemoteConfig (~> 11.0) - FirebaseSessions (~> 11.0) - GoogleDataTransport (~> 10.0) - GoogleUtilities/Environment (~> 8.0) - GoogleUtilities/MethodSwizzler (~> 8.0) - GoogleUtilities/UserDefaults (~> 8.0) - nanopb (~> 3.30910.0) - FirebaseRemoteConfig (11.1.0): - FirebaseABTesting (~> 11.0) - FirebaseCore (~> 11.0) - FirebaseInstallations (~> 11.0) - FirebaseRemoteConfigInterop (~> 11.0) - FirebaseSharedSwift (~> 11.0) - GoogleUtilities/Environment (~> 8.0) - "GoogleUtilities/NSData+zlib (~> 8.0)" - FirebaseRemoteConfigInterop (11.1.0) - FirebaseSessions (11.1.0): - FirebaseCore (~> 11.0) - FirebaseCoreExtension (~> 11.0) - FirebaseInstallations (~> 11.0) - GoogleDataTransport (~> 10.0) - GoogleUtilities/Environment (~> 8.0) - GoogleUtilities/UserDefaults (~> 8.0) - nanopb (~> 3.30910.0) - PromisesSwift (~> 2.1) - FirebaseSharedSwift (11.1.0) - Google-Maps-iOS-Utils (6.0.0): - GoogleMaps (~> 9.0) - GoogleAppMeasurement/WithoutAdIdSupport (11.1.0): - GoogleUtilities/AppDelegateSwizzler (~> 8.0) - GoogleUtilities/MethodSwizzler (~> 8.0) - GoogleUtilities/Network (~> 8.0) - "GoogleUtilities/NSData+zlib (~> 8.0)" - nanopb (~> 3.30910.0) - GoogleDataTransport (10.1.0): - nanopb (~> 3.30910.0) - PromisesObjC (~> 2.4) - GoogleMaps (9.1.1): - GoogleMaps/Maps (= 9.1.1) - GoogleMaps/Base (9.1.1) - GoogleMaps/Maps (9.1.1): - GoogleMaps/Base - GooglePlaces (9.1.0) - GoogleUtilities/AppDelegateSwizzler (8.0.2): - GoogleUtilities/Environment - GoogleUtilities/Logger - GoogleUtilities/Network - GoogleUtilities/Privacy - GoogleUtilities/Environment (8.0.2): - GoogleUtilities/Privacy - GoogleUtilities/Logger (8.0.2): - GoogleUtilities/Environment - GoogleUtilities/Privacy - GoogleUtilities/MethodSwizzler (8.0.2): - GoogleUtilities/Logger - GoogleUtilities/Privacy - GoogleUtilities/Network (8.0.2): - GoogleUtilities/Logger - "GoogleUtilities/NSData+zlib" - GoogleUtilities/Privacy - GoogleUtilities/Reachability - "GoogleUtilities/NSData+zlib (8.0.2)": - GoogleUtilities/Privacy - GoogleUtilities/Privacy (8.0.2) - GoogleUtilities/Reachability (8.0.2): - GoogleUtilities/Logger - GoogleUtilities/Privacy - GoogleUtilities/UserDefaults (8.0.2): - GoogleUtilities/Logger - GoogleUtilities/Privacy - GRMustache.swift (4.0.1) - nanopb (3.30910.0): - nanopb/decode (= 3.30910.0) - nanopb/encode (= 3.30910.0) - nanopb/decode (3.30910.0) - nanopb/encode (3.30910.0) - Periphery (2.21.0) - PromisesObjC (2.4.0) - PromisesSwift (2.4.0): - PromisesObjC (= 2.4.0) - SDWebImage (5.19.7): - SDWebImage/Core (= 5.19.7) - SDWebImage/Core (5.19.7) - SnapKit (5.7.1) - SwiftFormat/CLI (0.54.3) - SwiftLint (0.56.2) - Zip (2.1.2) DEPENDENCIES: - AEPAnalytics - AEPCore - AEPEdge - AEPIdentity - AEPLifecycle - Alamofire - Firebase/AnalyticsWithoutAdIdSupport - Firebase/Crashlytics - Firebase/DynamicLinks - Firebase/Performance - Google-Maps-iOS-Utils - GoogleMaps - GooglePlaces - GRMustache.swift - Periphery - SDWebImage - SnapKit - SwiftFormat/CLI - SwiftLint - Zip SPEC REPOS: trunk: - AEPAnalytics - AEPCore - AEPEdge - AEPEdgeIdentity - AEPIdentity - AEPLifecycle - AEPRulesEngine - AEPServices - Alamofire - Firebase - FirebaseABTesting - FirebaseAnalytics - FirebaseCore - FirebaseCoreExtension - FirebaseCoreInternal - FirebaseCrashlytics - FirebaseDynamicLinks - FirebaseInstallations - FirebasePerformance - FirebaseRemoteConfig - FirebaseRemoteConfigInterop - FirebaseSessions - FirebaseSharedSwift - Google-Maps-iOS-Utils - GoogleAppMeasurement - GoogleDataTransport - GoogleMaps - GooglePlaces - GoogleUtilities - GRMustache.swift - nanopb - Periphery - PromisesObjC - PromisesSwift - SDWebImage - SnapKit - SwiftFormat - SwiftLint - Zip SPEC CHECKSUMS: AEPAnalytics: 12ebcd98d08852d0ca824f91433336875e58335a AEPCore: db53082c207c28166ed6aa9ae6262a55e95c78aa AEPEdge: edf73ae8900016940cd7fcb29a89a576a1c6b0ae AEPEdgeIdentity: 3161ff33434586962946912d6b8e9e8fca1c4d23 AEPIdentity: 3c597ef3d734d726f6a48ae10cdecb36fbeb28ca AEPLifecycle: 0e2ddb26751320b88ea7471e63751f38c4ccdc10 AEPRulesEngine: fe5800653a4bee07b1e41e61b4d5551f0dba557b AEPServices: d959143d13fde7e8464c19527df6baacdef765ce Alamofire: f36a35757af4587d8e4f4bfa223ad10be2422b8c Firebase: fdb3bd378401f26a7adfcf446b0a630f8c20c0e8 FirebaseABTesting: c2e22c3aab99afa81d0561708b2c1c356c556976 FirebaseAnalytics: 9fcdb2e9844174bb405b34cc47092c9b91993d83 FirebaseCore: 6e2a2782e234b14d48e880ed369ac55cda87fed7 FirebaseCoreExtension: aa5c9779c2d0d39d83f1ceb3fdbafe80c4feecfa FirebaseCoreInternal: adefedc9a88dbe393c4884640a73ec9e8e790f8c FirebaseCrashlytics: 95cfe27373ff2edab39c28583d93cbf2dfff401d FirebaseDynamicLinks: 723659ea243225b831aeaf5959e0fe46cefed6ab FirebaseInstallations: d0a8fea5a6fa91abc661591cf57c0f0d70863e57 FirebasePerformance: 9303f34779bd99384838437c2b1fc1c1c9ff0d17 FirebaseRemoteConfig: 05521e937b72e01847a7128da5a492327364c705 FirebaseRemoteConfigInterop: abf8b1bbc0bf1b84abd22b66746926410bf91a87 FirebaseSessions: 78f137e68dc01ca71606169ba4ac73b98c13752a FirebaseSharedSwift: 260a35e08943ec810d820a70bc0359136351d0c5 Google-Maps-iOS-Utils: cfe6a0239c7ca634b7e001ad059a6707143dc8dc GoogleAppMeasurement: 8bb20efc67c8fc1cff9c42a06c256caf55289bbf GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 GoogleMaps: 80ea184ed6bf44139f383a8b0e248ba3ec1cc8c9 GooglePlaces: 00c43ad62c888354fe0bc5ce09181b2f6ce8b6d1 GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d GRMustache.swift: a6436504284b22b4b05daf5f46f77bd3fe00a9a2 nanopb: fad817b59e0457d11a5dfbde799381cd727c1275 Periphery: ee5accaac4ff9694d2bf60d52462fb1675c67c9d PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 SDWebImage: 8a6b7b160b4d710e2a22b6900e25301075c34cb3 SnapKit: d612e99e678a2d3b95bf60b0705ed0a35c03484a SwiftFormat: 0e575b1d412d27cd5906c59fab64a806ba8f2b8e SwiftLint: bd7cfb914762ab5f0cbb632964849571db075706 Zip: b3fef584b147b6e582b2256a9815c897d60ddc67 PODFILE CHECKSUM: c8547e28f06e09bac949f0daeaa0cf5f64ee30e0 COCOAPODS: 1.15.2 ```
google-oss-bot commented 1 week ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.