facebook / facebook-ios-sdk

Used to integrate the Facebook Platform with your iOS & tvOS apps.
https://developers.facebook.com/docs/ios
Other
7.73k stars 3.51k forks source link

Crash after upgrading to 5.4 from 5.2 (FBSDKLibAnalyzer.m line 51) #1020

Closed simonbengtsson closed 4 years ago

simonbengtsson commented 4 years ago

Most crashes seems to happen after the users starts the app. Can't see any patterns for device types, iOS versions etc. I have gotten the error a few times, but cannot reliably reproduce it. It has happened for about 10% of sessions.

Error:

FBSDKLibAnalyzer.m line 51
+[FBSDKLibAnalyzer getClassNames]
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000

Stacktrace:

Crashed: com.apple.root.background-qos
0  libsystem_platform.dylib       0x1ca894fc0 _platform_strncmp + 176
1  libobjc.A.dylib                0x1c9e9b034  + 72
2  libobjc.A.dylib                0x1c9e9ddf0  + 76
3  Foundation                     0x1cb709ad0 NSStringFromClass + 24
4  FBSDKCoreKit                   0x1032ea8f8 +[FBSDKLibAnalyzer getClassNames] + 51 (FBSDKLibAnalyzer.m:51)
5  FBSDKCoreKit                   0x1032ea760 +[FBSDKLibAnalyzer getMethodsTable] + 28 (FBSDKLibAnalyzer.m:28)
6  FBSDKCoreKit                   0x1032d11fc __42+[FBSDKCrashStorage generateMethodMapping]_block_invoke + 182 (FBSDKCrashStorage.m:182)
7  libdispatch.dylib              0x1ca69c308  + 32
8  libdispatch.dylib              0x1ca69d888  + 20
9  libdispatch.dylib              0x1ca6ac998  + 640
10 libdispatch.dylib              0x1ca6ad0f0  + 120
11 libsystem_pthread.dylib        0x1ca899b38 _pthread_wqthread + 468
12 libsystem_pthread.dylib        0x1ca89fdc4 start_wqthread + 4
simonbengtsson commented 4 years ago

Read the source code a little bit and seems a workaround might be setting Settings.isInstrumentEnabled to false. Will submit a new build to try that.

dreamolight commented 4 years ago

We deactivated the FBSDKLibAnalyzer at server side, so it won't trigger crash again. It's related to NSStringFromClass which is problematic, we'll fix the issue at SDK side in next release.

simonbengtsson commented 4 years ago

Sweet! Thanks.

megastep commented 4 years ago

Getting dozens of these crashes right now from my users, so I'm guessing it is not actually turned off on the server.

simonbengtsson commented 4 years ago

Same. Not as much as before but we had a spike an hour ago. What version of the sdk are you on @megastep? For us it spikes with 5.4.0 (in production) but happens on every app open with 5.4.1 (beta testing).

tianqibt commented 4 years ago

FBSDKLibAnalyzer was opened for 5.4.1. Now we turned off FBSDKLibAnalyzer for all version of SDK on server side. We will deliver fix in next release as soon as possible.

megastep commented 4 years ago

I am on 5.4.1 (app update was released just a couple of days ago). I see about 60 users reporting crashes in this exact code right up till now, so whatever happened on server side didn't entirely fix it, if at all.

What's the proper way to disable this so I can turn it off in future builds? I already send my crash reports to Firebase and don't want the FB SDK to step on its toes.

simonbengtsson commented 4 years ago

Looking at the code setting Settings.isAutoLogAppEventsEnabled = false should stop the sdk from init this. However after doing this it still crashes for us with this exception. It only crashes in prod environment and not in debug.

tianqibt commented 4 years ago

To debug the issue more efficiently, would you please invite us for internal testing of your app on TestFlight?

FBSDKLibAnalyzer in 5.4.1 was turned off on August 24 9:53PM. It had to take some time to be propagated to all servers and due to mobile cache, the crash will still exist for a short period of time. However, as time goes, the volume of crashes will be diminishing.

Facebook crash report is only collecting crashes caused by Facebook SDK for the purpose of making our SDK more stable. It is different from Firebase Crashlytics.

To properly turn off the crash report, you need to configure it in your app info.plist. https://developers.facebook.com/docs/app-events/getting-started-app-events-ios. "Disable Automatically Logged Events" section on this website will give you more information.

megastep commented 4 years ago

I'm looking at the crash reports in Firebase for that issue and it definitely seems to be coming down now. It peaked on Aug 24, so maybe there was just that delay.

My app is on the App Store right now here: https://apps.apple.com/us/app/fretuoso/id443265532

vazkir commented 4 years ago

I am just starting to get this crash, will there be an update to fix this?

simonbengtsson commented 4 years ago

We launched a new version with FacebookAutoLogAppEventsEnabled in Info.plist set to false and it that version we have not had a single crash. We still have crashes happening for users of previous versions but it is not as many as before.

tianqibt commented 4 years ago

@10686142 would you please provide the SDK version you are using? We delivered fix for this issue in v5.5.0.

silvinaroldan commented 4 years ago

@10686142 would you please provide the SDK version you are using? We delivered fix for this issue in v5.5.0.

I'm having the same crash on v.5.5.0. FBSDKCoreKit (5.5.0)

tianqibt commented 4 years ago

@silvamariana would you please attach the stack trace?

whswee-newswav commented 4 years ago

@tianqibt v.5.5.0

Crashed: com.apple.root.background-qos 0 libobjc.A.dylib 0x2160a4f28 objc_class::demangledName() + 32 1 FBSDKCoreKit 0x10115a234 +[FBSDKLibAnalyzer getClassNames] + 48 (FBSDKLibAnalyzer.m:48) 2 FBSDKCoreKit 0x10115a088 +[FBSDKLibAnalyzer getMethodsTable] + 28 (FBSDKLibAnalyzer.m:28) 3 FBSDKCoreKit 0x10114080c __42+[FBSDKCrashStorage generateMethodMapping]_block_invoke + 182 (FBSDKCrashStorage.m:182) 4 libdispatch.dylib 0x2168ffa38 _dispatch_call_block_and_release + 24 5 libdispatch.dylib 0x2169007d4 _dispatch_client_callout + 16 6 libdispatch.dylib 0x2168b1164 _dispatch_root_queue_drain + 680 7 libdispatch.dylib 0x2168b18d4 _dispatch_worker_thread2 + 128 8 libsystem_pthread.dylib 0x216ae11b4 _pthread_wqthread + 464 9 libsystem_pthread.dylib 0x216ae3cd4 start_wqthread + 4

tianqibt commented 4 years ago

The crash happens only in production or it is reproducible in debug mode? How do you integrate FBSDK to your app, via cocoapods? Would you please also provide your app name and app id? And it would be helpful if you can invite us as internal tester in testflight. Thanks!

silvamariana commented 4 years ago

@silvamariana would you please attach the stack trace?

psst, you tagged the wrong person.

tianqibt commented 4 years ago

@whswee-newswav and @silvinaroldan, would you please attach the following information to help us debug?

Thanks for your help!

luan-sala commented 4 years ago

Crash log:

Crashed: Mediated Adapter Initialization Queue 0 libsystem_kernel.dylib 0x1a3c50ebc __pthread_kill + 8 1 libsystem_pthread.dylib 0x1a3b70c1c pthread_kill$VARIANT$armv81 + 192 2 libsystem_c.dylib 0x1a3ac0824 abort + 100 3 libsystem_malloc.dylib 0x1a3b59b90 _malloc_put + 558 4 libsystem_malloc.dylib 0x1a3b59d48 malloc_report + 60 5 libsystem_malloc.dylib 0x1a3b4f120 free + 532 6 CoreFoundation 0x1a3e89b68 mdict_rehashd + 288 7 CoreFoundation 0x1a3d34140 -[NSDictionaryM setObject:forKey:] + 800 8 FBSDKCoreKit 0x1019a2350 +[FBSDKLibAnalyzer addClass:isClassMethod:] + 121 (FBSDKLibAnalyzer.m:121) 9 FBSDKCoreKit 0x1019a1c18 +[FBSDKLibAnalyzer getMethodsTable:frameworks:] + 40 (FBSDKLibAnalyzer.m:40) 10 FBSDKCoreKit 0x1019807d0 +[FBSDKCrashHandler generateMethodMapping:] + 280 (FBSDKCrashHandler.m:280) 11 FBSDKCoreKit 0x10197f630 +[FBSDKCrashHandler addObserver:] + 119 (FBSDKCrashHandler.m:119) 12 Letras 0x100e0497c -[FBAdContext setupServices] + 97 (FBAdContext.m:97) 13 Letras 0x100e046a4 -[FBAdContext init] + 52 (FBAdContext.m:52) 14 Letras 0x100e05808 29+[FBAdContext defaultContext]_block_invoke + 42 (FBAdContext.m:42) 15 libdispatch.dylib 0x1a3b26184 _dispatch_client_callout + 16 16 libdispatch.dylib 0x1a3af8f7c _dispatch_once_callout + 28 17 Letras 0x100e057e8 +[FBAdContext defaultContext] + 84 (once.h:84) 18 Letras 0x100e96e38 +[FBAudienceNetworkAds(Sync) performSynchronizationWithCompletion:] + 47 (FBAudienceNetworkAds+Sync.m:47) 19 Letras 0x100e96c6c +[FBAudienceNetworkAds initializeWithSettings:completionHandler:] + 95 (FBAudienceNetworkAds.m:95) 20 Letras 0x100345104 -[FacebookAdapterConfiguration initializeNetworkWithConfiguration:complete:] + 98 (FacebookAdapterConfiguration.m:98) 21 MoPub 0x101aeac1c __95-[MPMediationManager initializeWithAdditionalProviders:configurations:requestOptions:complete:]_block_invoke_2 + 136 (MPMediationManager.m:136) 22 libdispatch.dylib 0x1a3b25610 _dispatch_call_block_and_release + 24 23 libdispatch.dylib 0x1a3b26184 _dispatch_client_callout + 16 24 libdispatch.dylib 0x1a3b0373c _dispatch_lane_serial_drain$VARIANT$armv81 + 564 25 libdispatch.dylib 0x1a3b04154 _dispatch_lane_invoke$VARIANT$armv81 + 400 26 libdispatch.dylib 0x1a3b0d43c _dispatch_workloop_worker_thread + 576 27 libsystem_pthread.dylib 0x1a3b75fa4 _pthread_wqthread + 276 28 libsystem_pthread.dylib 0x1a3b78ae0 start_wqthread + 8

luan-sala commented 4 years ago

To debug the issue more efficiently, would you please invite us for internal testing of your app on TestFlight?

FBSDKLibAnalyzer in 5.4.1 was turned off on August 24 9:53PM. It had to take some time to be propagated to all servers and due to mobile cache, the crash will still exist for a short period of time. However, as time goes, the volume of crashes will be diminishing.

Facebook crash report is only collecting crashes caused by Facebook SDK for the purpose of making our SDK more stable. It is different from Firebase Crashlytics.

To properly turn off the crash report, you need to configure it in your app info.plist. https://developers.facebook.com/docs/app-events/getting-started-app-events-ios. "Disable Automatically Logged Events" section on this website will give you more information.

Ok, I was precipitated. I will do the mentioned above.

chaththaka commented 4 years ago

This crash started here on my application in production mode. Crash occurring either in iOS 12 and iOS 13. React native FBSDKCoreKit v4.34.0

Crash log: Crashed: com.apple.root.background-qos 0 libobjc.A.dylib 0x18912acb0 objc_class::demangledName() + 48 1 DSC 0x100972bb4 +[FBSDKLibAnalyzer getClassNames] + 47 (FBSDKLibAnalyzer.m:47) 2 DSC 0x100972a08 +[FBSDKLibAnalyzer getMethodsTable] + 28 (FBSDKLibAnalyzer.m:28) 3 DSC 0x10095902c __42+[FBSDKCrashStorage generateMethodMapping]_block_invoke + 182 (FBSDKCrashStorage.m:182) 4 libdispatch.dylib 0x1890a8b7c _dispatch_call_block_and_release + 32 5 libdispatch.dylib 0x1890a9fd8 _dispatch_client_callout + 20 6 libdispatch.dylib 0x1890b8cfc _dispatch_root_queue_drain + 644 7 libdispatch.dylib 0x1890b9384 _dispatch_worker_thread2 + 120 8 libsystem_pthread.dylib 0x18910f690 _pthread_wqthread + 216 9 libsystem_pthread.dylib 0x1891159e8 start_wqthread + 8

tianqibt commented 4 years ago

Would you please upgrade to the latest FBSDKCoreKit version 5.13.1?

ChinjuJames12 commented 4 years ago

iam using FBSDKCoreKit 5.4.1 But right now it started to crash in FBSDKCoreKit +[FBSDKLibAnalyzer getClassNames] in iOS 13.Anyway to solve it fast.To release a new version it will take time.

tianqibt commented 4 years ago

@ChinjuJames12 we have blacklisted this feature for version 5.4.1 on server side. We created a test app integrated with 5.4.1 and verified the feature has been disabled. Would you please double check the version number?

kukushi commented 3 years ago

@tianqibt Hello, we notice some similar crashes happened again, is there any server-side change?

The SDK version we using is:

 737   │   - FBSDKCoreKit (5.8.0):
 738   │     - FBSDKCoreKit/Basics (= 5.8.0)
 739   │     - FBSDKCoreKit/Core (= 5.8.0)
 740   │   - FBSDKCoreKit/Basics (5.8.0)
 741   │   - FBSDKCoreKit/Core (5.8.0):
 742   │     - FBSDKCoreKit/Basics
 743   │   - FBSDKLoginKit (5.8.0):
 744   │     - FBSDKLoginKit/Login (= 5.8.0)
 745   │   - FBSDKLoginKit/Login (5.8.0):
 746   │     - FBSDKCoreKit
 747   │   - FBSDKShareKit (5.8.0):
 748   │     - FBSDKShareKit/Share (= 5.8.0)
 749   │   - FBSDKShareKit/Share (5.8.0):
 750   │     - FBSDKCoreKit

The crash report looks like:

Thread 0 name:  com.apple.main-thread
Thread 0: Crashed
0   libobjc.A.dylib                 0x000000001ac2af4e realizeClass(objc_class*) (in libobjc.A.dylib) + 18
1   libobjc.A.dylib                 0x000000001ac2b05b realizeClass(objc_class*) (in libobjc.A.dylib) + 287
2   libobjc.A.dylib                 0x000000001ac2b05b realizeClass(objc_class*) (in libobjc.A.dylib) + 287
3   libobjc.A.dylib                 0x000000001ac2e90f objc_class::demangledName(bool) (in libobjc.A.dylib) + 227
4   libobjc.A.dylib                 0x000000001ac2e791 __objc_copyClassNamesForImage (in libobjc.A.dylib) + 165
5   XXX                           0x00000000010e870d +[FBSDKLibAnalyzer getClassesFrom:prefixes:] (in XXX) (FBSDKLibAnalyzer.m:79)
6   XXX                           0x00000000010e84c9 +[FBSDKLibAnalyzer getClassNames:frameworks:] (in XXX) (FBSDKLibAnalyzer.m:53)
7   XXX                           0x00000000010e831d +[FBSDKLibAnalyzer getMethodsTable:frameworks:] (in XXX) (FBSDKLibAnalyzer.m:35)
8   XXX                           0x00000000010d28fb +[FBSDKCrashHandler generateMethodMapping:] (in XXX) (FBSDKCrashHandler.m:280)
9   XXX                           0x00000000010d19af +[FBSDKCrashHandler addObserver:] (in XXX) (FBSDKCrashHandler.m:119)
10  XXX                           0x00000000010d2cf1 +[FBSDKCrashObserver enable] (in XXX) (FBSDKCrashObserver.m:46)
11  XXX                           0x00000000010daecf +[FBSDKGateKeeperManager loadGateKeepers:] (in XXX) (FBSDKGateKeeperManager.m:91)
12  XXX                           0x00000000010da8c3 +[FBSDKFeatureManager checkFeature:completionBlock:] (in XXX) (FBSDKFeatureManager.m:32)
13  XXX                           0x00000000010e4f37 +[FBSDKInstrumentManager enable] (in XXX) (FBSDKInstrumentManager.m:39)
14  XXX                           0x00000000010db997 +[FBSDKGateKeeperManager _didProcessGKFromNetwork:] (in XXX) (FBSDKGateKeeperManager.m:181)
15  XXX                           0x00000000010db815 +[FBSDKGateKeeperManager processLoadRequestResponse:error:] (in XXX) (FBSDKGateKeeperManager.m:171)
16  XXX                           0x00000000010db10d __42+[FBSDKGateKeeperManager loadGateKeepers:]_block_invoke (in XXX) (FBSDKGateKeeperManager.m:104)
17  XXX                           0x00000000010e320f -[FBSDKGraphRequestMetadata invokeCompletionHandlerForConnection:withResults:error:] (in XXX) (FBSDKGraphRequestMetadata.m:41)
18  XXX                           0x00000000010e0f55 __82-[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:]_block_invoke (in XXX) (FBSDKGraphRequestConnection.m:801)
19  XXX                           0x00000000010e0e7b -[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:] (in XXX) (FBSDKGraphRequestConnection.m:834)
20  XXX                           0x00000000010e0a97 __64-[FBSDKGraphRequestConnection completeWithResults:networkError:]_block_invoke (in XXX) (FBSDKGraphRequestConnection.m:783)
21  CoreFoundation                  0x000000001b8be361 ___53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke (in CoreFoundation) + 87
22  CoreFoundation                  0x000000001b8be23f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] (in CoreFoundation) + 159
23  XXX                           0x00000000010e093f -[FBSDKGraphRequestConnection completeWithResults:networkError:] (in XXX) (FBSDKGraphRequestConnection.m:762)
24  XXX                           0x00000000010dfecf -[FBSDKGraphRequestConnection completeFBSDKURLSessionWithResponse:data:networkError:] (in XXX) (FBSDKGraphRequestConnection.m:629)
25  XXX                           0x00000000010de4df __36-[FBSDKGraphRequestConnection start]_block_invoke_3 (in XXX) (FBSDKGraphRequestConnection.m:242)
26  libdispatch.dylib               0x000000001b06d797 __dispatch_call_block_and_release (in libdispatch.dylib) + 11
27  libdispatch.dylib               0x000000001b06d783 __dispatch_client_callout (in libdispatch.dylib) + 23
28  libdispatch.dylib               0x000000001b071d05 __dispatch_main_queue_callback_4CF (in libdispatch.dylib) + 903
29  CoreFoundation                  0x000000001b95bd69 ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (in CoreFoundation) + 9
30  CoreFoundation                  0x000000001b959e19 ___CFRunLoopRun (in CoreFoundation) + 849
31  CoreFoundation                  0x000000001b8ad1af _CFRunLoopRunSpecific (in CoreFoundation) + 471
32  CoreFoundation                  0x000000001b8acfd1 _CFRunLoopRunInMode (in CoreFoundation) + 105
33  GraphicsServices                0x000000001d057b41 _GSEventRunModal (in GraphicsServices) + 81
34  UIKit                           0x0000000020c35a53 _UIApplicationMain (in UIKit) + 151
35  XXX                           0x0000000000016705 main (in XXX) (<compiler-generated>:11)
36  libdyld.dylib                   0x000000001b09a4eb _start (in libdyld.dylib) + 3
tianqibt commented 3 years ago

@kukushi, there's no server side change. Please upgrade to the latest version of SDK.

kukushi commented 3 years ago

@kukushi, there's no server side change. Please upgrade to the latest version of SDK.

Thanks for replying. Would you mind sharing the problem of NSStrongFromClass mentioned in this thread?