firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Firebase 8.10.0 crashes on FIRCLSFileWriteString

Open sdduursma opened this issue 2 years ago • 8 comments

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 13.4.1
  • Firebase SDK version: 8.10.0
  • Installation method: Swift Package Manager via https://github.com/akaffenberger/firebase-ios-sdk-xcframeworks
  • Firebase Component: Crashlytics
  • Target platform(s): iOS

[REQUIRED] Step 2: Describe the problem

We have received a number of reports of a crash in FIRCLSFileWriteString (see below). The crash looks the same as the one reported in https://github.com/firebase/firebase-ios-sdk/issues/9254. In that issue, the author eliminated calls to Crashlytics during pre-warming and that appeared to resolve the crash. But as far as I'm aware, we don't make any calls to Crashlytics during pre-warming.

[...]

Date/Time:           2022-08-12 08:40:22.1238 -0300
Launch Time:         2022-08-11 19:02:47.6797 -0300
OS Version:          iPhone OS 15.6 (19G71)
Release Type:        User
Baseband Version:    3.04.01
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0xfffffffd7ea0fc40
Exception Codes: 0x0000000000000001, 0xfffffffd7ea0fc40
VM Region Info: 0xfffffffd7ea0fc40 is not in any region.  Bytes after previous region: 18446743581912792129  
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      commpage (reserved)     1000000000-7000000000 [384.0G] ---/--- SM=NUL  ...(unallocated)
--->  
      UNUSED SPACE AT END
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [96963]

Triggered by Thread:  12


[...]

Thread 12 name:
Thread 12 Crashed:
0   libsystem_platform.dylib        0x00000002112ccfc4 _platform_strlen + 4
1   AppName                         0x0000000102fe5f98 FIRCLSFileWriteString + 32
2   AppName                         0x0000000102fe5f64 FIRCLSFileWriteHashEntryString + 36
3   AppName                         0x0000000102fdd898 __FIRCLSContextInitialize_block_invoke_5 + 424
4   libdispatch.dylib               0x000000019fd7ae6c _dispatch_call_block_and_release + 32 (init.c:1517)
5   libdispatch.dylib               0x000000019fd7ca30 _dispatch_client_callout + 20 (object.m:560)
6   libdispatch.dylib               0x000000019fd7fc1c _dispatch_queue_override_invoke + 1000 (inline_internal.h:2608)
7   libdispatch.dylib               0x000000019fd8e164 _dispatch_root_queue_drain + 396 (inline_internal.h:0)
8   libdispatch.dylib               0x000000019fd8e96c _dispatch_worker_thread2 + 164 (queue.c:6935)
9   libsystem_pthread.dylib         0x00000002112d5080 _pthread_wqthread + 228 (pthread.c:2612)
10  libsystem_pthread.dylib         0x00000002112d4e5c start_wqthread + 8 (:-1)

[...]

EOF

Steps to reproduce:

We are unable to reproduce the crash, but we see it in production in Xcode Organizer.

Relevant Code:

None

sdduursma avatar Aug 16 '22 11:08 sdduursma

@sdduursma the code path being triggered here is Crashlytics' initialization code, which is invoked when you configure your app iirc. Can you check if the crashes are only occurring on iOS 15 and above?

morganchen12 avatar Aug 17 '22 18:08 morganchen12

From what I can see in Xcode, the crashes are only occurring on iOS 15.

sdduursma avatar Aug 22 '22 10:08 sdduursma

Got it--and you're configuring Firebase in your app's didFinishLaunchingWithOptions: method?

morganchen12 avatar Aug 22 '22 21:08 morganchen12

We use SwiftUI so Firebase is configured in our App's initialiser.

sdduursma avatar Aug 23 '22 09:08 sdduursma

Makes sense. This doc implies the init method should run before didFinishLaunchingWithOptions:, so you may be able to resolve this crash by adding an @UIApplicationDelegateAdaptor and moving your Firebase initialization there.

morganchen12 avatar Aug 23 '22 17:08 morganchen12

This issue has reproduced with Firebase SDK version 9.3.0. Is there any solution for this issue?

Date/Time:           2022-10-09 09:32:08.3923 +0900
Launch Time:         2022-10-09 09:12:58.8126 +0900
OS Version:          iPhone OS 15.6.1 (19G82)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0400000100000000
Exception Codes: 0x0000000000000001, 0x0400000100000000
VM Region Info: 0x400000100000000 is not in any region.  Bytes after previous region: 288229899410341889  
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      commpage (reserved)     1000000000-7000000000 [384.0G] ---/--- SM=NUL  ...(unallocated)
--->  
      UNUSED SPACE AT END
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [15283]

Triggered by Thread:  48

Thread 48 name:   Dispatch queue: com.apple.root.default-qos
Thread 48 Crashed:
0   libsystem_platform.dylib      	       0x1dd6d7f24 _platform_strlen + 4
1   AppName                     	       0x10236653c FIRCLSFileWriteString + 31 (FIRCLSFile.m:346)
2   AppName                     	       0x102366508 FIRCLSFileWriteHashEntryString + 35 (FIRCLSFile.m:547)
3   AppName                     	       0x10235d3a0 FIRCLSContextRecordIdentity + 247 (FIRCLSContext.m:371) [inlined]
4   AppName                     	       0x10235d3a0 FIRCLSContextRecordMetadata + 327 (FIRCLSContext.m:417) [inlined]
5   AppName                     	       0x10235d3a0 __FIRCLSContextInitialize_block_invoke_5 + 423 (FIRCLSContext.m:214)
6   libdispatch.dylib             	       0x183071094 _dispatch_call_block_and_release + 24
7   libdispatch.dylib             	       0x183072094 _dispatch_client_callout + 16
8   libdispatch.dylib             	       0x183014924 _dispatch_queue_override_invoke + 924
9   libdispatch.dylib             	       0x183021b94 _dispatch_root_queue_drain + 340
10  libdispatch.dylib             	       0x18302239c _dispatch_worker_thread2 + 172
11  libsystem_pthread.dylib       	       0x1dd6e4dd4 _pthread_wqthread + 224
12  libsystem_pthread.dylib       	       0x1dd6e493c start_wqthread + 8

naoigcat avatar Nov 02 '22 09:11 naoigcat

@naoigcat have you tried moving your Firebase initialization to application(_: didFinishLaunchingWithOptions:)?

morganchen12 avatar Nov 02 '22 21:11 morganchen12

@morganchen12

I have configured the Firebase with [FIRApp configure] in -[AppDelegate application:didFinishLaunchingWithOptions:].

naoigcat avatar Nov 07 '22 08:11 naoigcat