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

Data race in FBSDKLogger #2201

Open
5 tasks done
jacobsapps opened this issue May 5, 2023 · 2 comments
Open
5 tasks done

Data race in FBSDKLogger #2201

jacobsapps opened this issue May 5, 2023 · 2 comments

Comments

@jacobsapps
Copy link

Checklist before submitting a bug report

Xcode version

14.3

Facebook iOS SDK version

16.0.0

Dependency Manager

SPM

SDK Framework

Core

Goals

I don't want my app to crash because of the Facebook SDK.

Expected results

I don't want my app to crash because of the Facebook SDK.

Actual results

Data races are being warned against by Thread Sanitizer.

This makes me a little anxious; since it introduces a potential crash source under which I have no control. Would you be able to investigate this please?

Steps to reproduce

  1. Integrate FB sdk
  2. Turn on TSan
  3. Run app

Code samples & details

`/facebook-ios-sdk/FBSDKCoreKit/FBSDKCoreKit/FBSDKLogger.m:195 Race on a library object in +[FBSDKLogger registerStringToReplace:replaceWith:] at 0x11a519380`

`Location is a 32-byte heap object at 0x11a519380`

After calling `FacebookCore.ApplicationDelegate.shared.application(UIApplication.shared, didFinishLaunchingWithOptions: launchOptions)` after launch:


Mutex M0 created
#0	0x000000010a3812f0 in wrap_objc_sync_enter ()
#1	0x0000000105b2396c in -[FBSDKAppEventsConfigurationManager loadAppEventsConfigurationWithBlock:] at /facebook-ios-sdk/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/FBSDKAppEventsConfigurationManager.m:80

After calling FacebookCore.ApplicationDelegate.shared.application(UIApplication.shared, didFinishLaunchingWithOptions: launchOptions) after SceneDelegate sceneDidBecomeActive:

Mutating access by thread 1
#0	0x000000018045344c in -[__NSDictionaryM setObject:forKey:] ()
#1	0x0000000105b48720 in +[FBSDKLogger registerStringToReplace:replaceWith:] at /facebook-ios-sdk/FBSDKCoreKit/FBSDKCoreKit/FBSDKLogger.m:195
@aleufms
Copy link

aleufms commented Jun 12, 2023

After I updated Facebook SDK to 16.0.1 (from 14.1.0), the crashlytics begins to register some new crashes in the [FBSDKLogger registerStringToReplace:replaceWith:] method:

Crashed: com.apple.main-thread
0  CoreFoundation                 0x2a15c cow_cleanup + 120
1  CoreFoundation                 0x62458 -[__NSDictionaryM dealloc] + 148
2  Foundry                        0x409188 +[FBSDKLogger registerStringToReplace:replaceWith:] + 195 (FBSDKLogger.m:195)
3  Foundry                        0x4026e0 -[FBSDKGraphRequestConnection registerTokenToOmitFromLog:] + 1254 (FBSDKGraphRequestConnection.m:1254)
4  Foundry                        0x3ff6e8 -[FBSDKGraphRequestConnection urlStringForSingleRequest:forBatch:] + 691 (FBSDKGraphRequestConnection.m:691)
5  Foundry                        0x3ff104 -[FBSDKGraphRequestConnection requestWithBatch:timeout:] + 581 (FBSDKGraphRequestConnection.m:581)
6  Foundry                        0x3fdee4 -[FBSDKGraphRequestConnection start] + 360 (FBSDKGraphRequestConnection.m:360)
7  Foundry                        0x3fc5bc -[FBSDKGraphRequest startWithCompletion:] + 194 (FBSDKGraphRequest.m:194)
8  Foundry                        0x3e23c4 __45-[FBSDKAppEvents flushOnMainQueue:forReason:]_block_invoke + 1265 (FBSDKAppEvents.m:1265)
9  Foundry                        0x3e09d4 __43-[FBSDKAppEvents fetchServerConfiguration:]_block_invoke_2 + 1000 (FBSDKAppEvents.m:1000)
10 Foundry                        0x41b54c -[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:] + 188 (FBSDKServerConfigurationManager.m:188)
11 Foundry                        0x3e05ac __43-[FBSDKAppEvents fetchServerConfiguration:]_block_invoke + 927 (FBSDKAppEvents.m:927)
12 Foundry                        0x3e4584 -[FBSDKAppEventsConfigurationManager _processResponse:error:] + 124 (FBSDKAppEventsConfigurationManager.m:124)
13 Foundry                        0x403744 -[FBSDKGraphRequestMetadata invokeCompletionHandlerForConnection:withResults:error:] + 32 (FBSDKGraphRequestMetadata.m:32)
14 Foundry                        0x400e40 __82-[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:]_block_invoke + 967 (FBSDKGraphRequestConnection.m:967)
15 Foundry                        0x400d60 -[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:] + 1000 (FBSDKGraphRequestConnection.m:1000)
16 Foundry                        0x400a04 __65-[FBSDKGraphRequestConnection _completeWithResults:networkError:]_block_invoke + 949 (FBSDKGraphRequestConnection.m:949)
17 CoreFoundation                 0xa1cc __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 24
18 CoreFoundation                 0x25824 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 196
19 Foundry                        0x4007b4 -[FBSDKGraphRequestConnection _completeWithResults:networkError:] + 926 (FBSDKGraphRequestConnection.m:926)
20 Foundry                        0x3ffcf0 -[FBSDKGraphRequestConnection completeFBSDKURLSessionWithResponse:data:networkError:] + 783 (FBSDKGraphRequestConnection.m:783)
21 libdispatch.dylib              0x2320 _dispatch_call_block_and_release + 32
22 libdispatch.dylib              0x3eac _dispatch_client_callout + 20
23 libdispatch.dylib              0x126a4 _dispatch_main_queue_drain + 928
24 libdispatch.dylib              0x122f4 _dispatch_main_queue_callback_4CF + 44
25 CoreFoundation                 0x98c28 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
26 CoreFoundation                 0x7a560 __CFRunLoopRun + 1992
27 CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
28 GraphicsServices               0x135c GSEventRunModal + 164
29 UIKitCore                      0x39d6e8 -[UIApplication _run] + 888
30 UIKitCore                      0x39d34c UIApplicationMain + 340
31 enjoei                         0x3079c main + 13 (main.swift:13)
32 ???                            0x1bdf96dec (Missing)

@aleufms
Copy link

aleufms commented Jun 12, 2023

#2182 would be same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@aleufms @jacobsapps and others