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

Data race resulting in crash in logic related to `FIRAuth` instance vars / `[FIRAuth getTokenForcingRefresh]`

Open bryansum opened this issue 1 year ago • 3 comments

Description

One of the top crashes in our widget seems to happen in Firebase Auth. In the widget, we only use Firebase to call a Firebase function, which means calling FIRAuth.useUserAccessGroup:

Screenshot 2024-02-09 at 16 25 49

Then calling Auth().auth.currentUser to see if we're logged in, and then calling the requisite Firebase functions (which crucially seems to call FIRAuth.getTokenForcingRefresh internally).

Note that the widget process can potentially be reused across multiple widgets' refreshes, so this code can be called more than once per process lifetime (furthermore, some of these crashes seem to happening during an overlap in FIRAuth.getTokenForcingRefresh calls with some other FIRAuth access in our widget's initialization code, which could only happen with multiple simultaneous widget refreshes).

Unfortunately in rare cases we get segfaults related to auth code:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Codes: 0x0000000000000001, 0x0000000000000020
VM Region Info: 0x20 is not in any region.  Bytes before following region: 68719476704
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      commpage (reserved)     1000000000-7000000000 [384.0G] ---/--- SM=NUL  ...(unallocated)
Termination Reason: SIGNAL 11 Segmentation fault: 11

More specifically, we seem to be seeing segfaults at some address calling objc_msgSend on presumably an instance var accessed in __copy_helper_block or __destroy_helper_block functions (which are generated for FIRAuth.m code as per crash reports):

Screenshot 2024-02-09 at 15 19 54

From what I understand these __copy_helper_block / __destroy_helper_block functions are generated by the compiler at GCD block boundaries in order to retain / release closed over variables.

Without looking at the assembly directly, my best guess is that this segfault is mostly likely related to the capture of FIRAuth._currentUser at some point, which is referenced in FIRAuth but is not consistently accessed / mutated in a synchronized way (see updateCurrentUser which can reset _currentUser = nil without locks, for instance, and is called both via useUserAccessGroup on an arbitrary thread in an unsynchronized manner by the user as well as on the FIRAuthGlobalWorkQueue via FIRAuth.getTokenForcingRefresh). On inspection, it seems plausible that _currentUser could be captured and mutated in an unsafe way in certain instances.

Screenshot 2024-02-09 at 16 34 13 Screenshot 2024-02-09 at 14 33 27 Screenshot 2024-02-09 at 14 10 17

Reproducing the issue

Hard to pin down exactly, but my guess would be trying to repro a case where _currentUser is set and accessed on different threads, which, for example, could happen after first setting _currentUser from disk via useUserAccessGroup (which in our case happens on the main thread, synchronously), at the same time as calling FIRAuth.getTokenForcingRefresh. Interestingly FIRUser.internalGetTokenForcingRefresh seems to block copy its self argument implicitly here. Or this could even happen potentially in FIRAuth.getTokenForcingRefresh alone, which calls into FIRUser.internalGetTokenForcingRefresh on _currentUser while that same function can reset _currentUser via signOutIfTokenIsInvalidWithError if the refresh token is invalid.

Firebase SDK Version

10.21.0

Xcode Version

15.2

Installation Method

Swift Package Manager

Firebase Product(s)

Authentication

Targeted Platforms

iOS

Relevant Log Output

Incident Identifier: F7819BFE-6162-456A-9EDB-8133302344E2
Hardware Model:      iPhone15,2
Process:             LocketWidgetExtension [15430]
Path:                /private/var/containers/Bundle/Application/F00367F9-A594-403E-9D6D-546183B3102D/Locket.app/PlugIns/LocketWidgetExtension.appex/LocketWidgetExtension
Identifier:          com.locket.Locket.LocketWidget
Version:             1.56.0 (1)
AppVariant:          1:iPhone15,2:16
Code Type:           ARM-64 (Native)
Role:                Unspecified
Parent Process:      launchd [1]
Coalition:           com.locket.Locket.LocketWidget [2431]

Date/Time:           2024-01-26 11:36:59.1733 +0700
Launch Time:         2024-01-26 09:29:01.8229 +0700
OS Version:          iPhone OS 16.6.1 (20G81)
Release Type:        User
Baseband Version:    1.80.02
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x8031001b01a9a180 -> 0x0000001b01a9a180 (possible pointer authentication failure)
Exception Codes: 0x0000000000000001, 0x8031001b01a9a180
VM Region Info: 0x1b01a9a180 is in 0x1000000000-0x7000000000;  bytes after start: 47272534400  bytes before end: 365044326015
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      commpage (reserved)      fc0000000-1000000000 [  1.0G] ---/--- SM=NUL  ...(unallocated)
--->  GPU Carveout (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL  ...(unallocated)
      UNUSED SPACE AT END
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [15430]

Triggered by Thread:  2


Thread 0 name:
Thread 0:
0   libswiftCore.dylib            	0x00000001b012a0fc getCache(swift::TargetTypeContextDescriptor<swift::InProcess> const&) + 1948 (Metadata.cpp:443)
1   libswift_Concurrency.dylib    	0x00000001c0401b10 __swift_instantiateGenericMetadata + 32 (<compiler-generated>:0)
2   libswift_Concurrency.dylib    	0x00000001c03e8810 AsyncStream.Continuation.yield(_:) + 24 (AsyncStream.swift:196)
3   LocketWidgetExtension         	0x0000000100e2e49c closure #1 in implicit closure #1 in closure #1 in closure #2 in variable initialization expression of static AuthClient.liveValue + 188 (AuthClientLive.swift:0)
4   LocketWidgetExtension         	0x0000000100e2e518 thunk for @escaping @callee_guaranteed (@guaranteed FIRAuth, @guaranteed FIRUser?) -> () + 80 (<compiler-generated>:0)
5   LocketWidgetExtension         	0x0000000100c15130 __41-[FIRAuth addAuthStateDidChangeListener:]_block_invoke + 280 (FIRAuth.m:1674)
6   libdispatch.dylib             	0x00000001bd50e320 _dispatch_call_block_and_release + 32 (init.c:1518)
7   libdispatch.dylib             	0x00000001bd50feac _dispatch_client_callout + 20 (object.m:560)
8   libdispatch.dylib             	0x00000001bd51e6a4 _dispatch_main_queue_drain + 928 (queue.c:7794)
9   libdispatch.dylib             	0x00000001bd51e2f4 _dispatch_main_queue_callback_4CF + 44 (queue.c:7954)
10  CoreFoundation                	0x00000001b60d7c28 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
11  CoreFoundation                	0x00000001b60b9560 __CFRunLoopRun + 1992 (CFRunLoop.c:3147)
12  CoreFoundation                	0x00000001b60be3ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
13  Foundation                    	0x00000001b0332fb4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
14  Foundation                    	0x00000001b0332e48 -[NSRunLoop(NSRunLoop) run] + 64 (NSRunLoop.m:398)
15  libxpc.dylib                  	0x0000000215ed6678 _xpc_objc_main + 496 (main.m:246)
16  libxpc.dylib                  	0x0000000215ed8924 xpc_main + 156 (init.c:1258)
17  Foundation                    	0x00000001b037a910 -[NSXPCListener resume] + 312 (NSXPCListener.m:460)
18  ExtensionFoundation           	0x00000001c367e658 -[_EXRunningExtension resume] + 204 (EXRunningExtension.m:250)
19  ExtensionFoundation           	0x00000001c367e4f0 -[_EXRunningExtension startWithArguments:count:] + 188 (EXRunningExtension.m:228)
20  ExtensionFoundation           	0x00000001c369e520 EXExtensionMain + 220 (EXExtensionMain.m:31)
21  Foundation                    	0x00000001b03bede0 NSExtensionMain + 204 (NSExtensionMain.m:21)
22  dyld                          	0x00000001d55f0dec start + 2220 (dyldMain.cpp:1165)

Thread 1 name:
Thread 1:
0   libsystem_kernel.dylib        	0x00000001f4ffeca4 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib        	0x00000001f5011b74 mach_msg2_internal + 80 (mach_msg.c:201)
2   libsystem_kernel.dylib        	0x00000001f5011e4c mach_msg_overwrite + 540 (mach_msg.c:0)
3   libsystem_kernel.dylib        	0x00000001f4fff1e8 mach_msg + 24 (mach_msg.c:323)
4   CoreFoundation                	0x00000001b60b8024 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2622)
5   CoreFoundation                	0x00000001b60b9250 __CFRunLoopRun + 1208 (CFRunLoop.c:3005)
6   CoreFoundation                	0x00000001b60be3ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
7   CFNetwork                     	0x00000001b72a96f0 +[__CFN_CoreSchedulingSetRunnable _run:] + 392 (CoreSchedulingSet.mm:1562)
8   Foundation                    	0x00000001b034c524 __NSThread__start__ + 716 (NSThread.m:963)
9   libsystem_pthread.dylib       	0x0000000215e7a6b8 _pthread_start + 148 (pthread.c:893)
10  libsystem_pthread.dylib       	0x0000000215e79b88 thread_start + 8 (:-1)

Thread 2 name:
Thread 2 Crashed:
0   libobjc.A.dylib               	0x00000001af0c6820 objc_msgSend + 32 (:-1)
1   LocketWidgetExtension         	0x0000000100c100cc __copy_helper_block_e8_32s40b + 28 (FIRAuth.m:0)
2   libsystem_blocks.dylib        	0x0000000215e760d0 _call_copy_helpers_excp + 80 (generic_helpers.c:23)
3   libsystem_blocks.dylib        	0x0000000215e75c38 _Block_copy + 356 (runtime.cpp:909)
4   libdispatch.dylib             	0x00000001bd50e2e4 _dispatch_Block_copy + 32 (init.c:1506)
5   libdispatch.dylib             	0x00000001bd5147fc dispatch_async + 56 (queue.c:925)
6   LocketWidgetExtension         	0x0000000100c19490 -[FIRAuthSerialTaskQueue enqueueTask:] + 100 (FIRAuthSerialTaskQueue.m:42)
7   LocketWidgetExtension         	0x0000000100c371e0 -[FIRSecureTokenService fetchAccessTokenForcingRefresh:callback:] + 112 (FIRSecureTokenService.m:98)
8   LocketWidgetExtension         	0x0000000100c3bcc4 -[FIRUser internalGetTokenForcingRefresh:callback:] + 112 (FIRUser.m:1021)
9   LocketWidgetExtension         	0x0000000100c1874c __47-[FIRAuth getTokenForcingRefresh:withCallback:]_block_invoke + 504 (FIRAuth.m:2556)
10  libdispatch.dylib             	0x00000001bd50e320 _dispatch_call_block_and_release + 32 (init.c:1518)
11  libdispatch.dylib             	0x00000001bd50feac _dispatch_client_callout + 20 (object.m:560)
12  libdispatch.dylib             	0x00000001bd517534 _dispatch_lane_serial_drain + 668 (queue.c:3885)
13  libdispatch.dylib             	0x00000001bd5180a4 _dispatch_lane_invoke + 384 (queue.c:3976)
14  libdispatch.dylib             	0x00000001bd522cdc _dispatch_workloop_worker_thread + 648 (queue.c:6507)
15  libsystem_pthread.dylib       	0x0000000215e79ddc _pthread_wqthread + 288 (pthread.c:2618)
16  libsystem_pthread.dylib       	0x0000000215e79b7c start_wqthread + 8 (:-1)

Thread 3:
0   libsystem_pthread.dylib       	0x0000000215e79b74 start_wqthread + 0 (:-1)

Thread 4:
0   CoreFoundation                	0x00000001b60c094c __NSCFDictionaryCreateMutable + 288 (NSPlaceholderDictionary.m:196)
1   libswiftCore.dylib            	0x00000001b0166e8c objcRetainAndReturn(void*) + 32 (SwiftObject.mm:591)
2   LocketWidgetExtension         	0x0000000100a62c30 LocketGenericProvider.getTimeline(configuration:kind:size:) + 104 (LocketGenericProvider.swift:0)
3   LocketWidgetExtension         	0x0000000100a59cc5 closure #1 in LocketIntentTimelineProvider.getTimeline(for:in:completion:) + 1 (LocketTimelineProviders.swift:44)
4   LocketWidgetExtension         	0x0000000100a59f89 partial apply for closure #1 in LocketIntentTimelineProvider.getTimeline(for:in:completion:) + 1 (<compiler-generated>:0)
5   LocketWidgetExtension         	0x0000000100a7d1f1 specialized thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A) + 1 (<compiler-generated>:0)
6   LocketWidgetExtension         	0x0000000100a5a0f1 partial apply for specialized thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A) + 1 (<compiler-generated>:0)
7   libswift_Concurrency.dylib    	0x00000001c040add9 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:496)

Thread 5:
0   libsystem_pthread.dylib       	0x0000000215e79b74 start_wqthread + 0 (:-1)


Thread 2 crashed with ARM Thread State (64-bit):
    x0: 0x0000000101a3cb80   x1: 0x00000001b12f924d   x2: 0x00000001015e8ca8   x3: 0x0000000100c100b0
    x4: 0x00000000000001e0   x5: 0x0000000000000020   x6: 0x000000016f68e708   x7: 0x0000000000000000
    x8: 0x00000000c2000000   x9: 0x8031001a00000000  x10: 0x000000020ca27f30  x11: 0x0000000000007fff
   x12: 0x0000000000013d80  x13: 0x0000000040b00013  x14: 0x0000000101a9a170  x15: 0x0000000101a9a170
   x16: 0x8031001b01a9a170  x17: 0x0000000000000001  x18: 0x0000000000000000  x19: 0x000000016f68e6b0
   x20: 0x000000010300a490  x21: 0x0000000000000030  x22: 0x000000016f68f0e0  x23: 0x000000016f68e7f0
   x24: 0x0000000101b43668  x25: 0x0000000000000000  x26: 0x0000000000000114  x27: 0x0000000000000000
   x28: 0x0000000103100c00   fp: 0x000000016f68e5b0   lr: 0x0000000100c100cc
    sp: 0x000000016f68e5a0   pc: 0x00000001af0c6820 cpsr: 0x20001000
   esr: 0x92000004 (Data Abort) byte read Translation fault


Binary Images:
        0x100a28000 -         0x1015cffff LocketWidgetExtension arm64  <9dad5f4f043d3b52a86f14beb776f627> /private/var/containers/Bundle/Application/F00367F9-A594-403E-9D6D-546183B3102D/Locket.app/PlugIns/LocketWidgetExtension.appex/LocketWidgetExtension
        0x10c814000 -         0x10c81ffff libobjc-trampolines.dylib arm64e  <7e77fc541c3331c086e81fb7bf12836c> /private/preboot/Cryptexes/OS/usr/lib/libobjc-trampolines.dylib
        0x1af0c4000 -         0x1af107f9f libobjc.A.dylib arm64e  <eb7faf215c9f37848907affa6d92bc3b> /usr/lib/libobjc.A.dylib
        0x1afd64000 -         0x1b02bcfff libswiftCore.dylib arm64e  <a4726d93179833868c5872e17d96a1a4> /usr/lib/swift/libswiftCore.dylib
        0x1b02f1000 -         0x1b0bcefff Foundation arm64e  <1715de5d08933af0b0c0550bb14f91ec> /System/Library/Frameworks/Foundation.framework/Foundation
        0x1b603f000 -         0x1b6426fff CoreFoundation arm64e  <a900b4590127379e9cba0eab9c5d559f> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
        0x1b7051000 -         0x1b741bfff CFNetwork arm64e  <045d4271e64e3229a49fcaff707aa77f> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
        0x1bd50c000 -         0x1bd552fff libdispatch.dylib arm64e  <5d16936b4e4c3276ba7a69c9bc760aba> /usr/lib/system/libdispatch.dylib
        0x1c03c2000 -         0x1c041dffb libswift_Concurrency.dylib arm64e  <53afe373f6c9315bad6959c8ff1d65e7> /usr/lib/swift/libswift_Concurrency.dylib
        0x1c367c000 -         0x1c36dffff ExtensionFoundation arm64e  <f5a02c51648b3b18a02d00b0e0a3e34c> /System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation
        0x1d55db000 -         0x1d5660a53 dyld arm64e  <c3fc2ee4367f3086beb8420ad442bf88> /usr/lib/dyld
        0x1f4ffe000 -         0x1f5035fe7 libsystem_kernel.dylib arm64e  <681b06a07f6b3fa3a2ce063dc1da7b1b> /usr/lib/system/libsystem_kernel.dylib
        0x215e74000 -         0x215e78ff8 libsystem_blocks.dylib arm64e  <f4dcca1107393c4ba2fb711121760730> /usr/lib/system/libsystem_blocks.dylib
        0x215e79000 -         0x215e84ff3 libsystem_pthread.dylib arm64e  <aa302f5affe5327aa0033b288b935de1> /usr/lib/system/libsystem_pthread.dylib
        0x215ebc000 -         0x215efdfff libxpc.dylib arm64e  <a0d322a3d7723260969071f28737c43c> /usr/lib/system/libxpc.dylib

EOF

################ Other stack trace

Incident Identifier: 197FE786-BE5C-46EF-8E36-2143D415A067
Hardware Model:      iPhone14,5
Process:             LocketWidgetExtension [11694]
Path:                /private/var/containers/Bundle/Application/C94C7F7B-E082-48BC-A17F-70B56638CC35/Locket.app/PlugIns/LocketWidgetExtension.appex/LocketWidgetExtension
Identifier:          com.locket.Locket.LocketWidget
Version:             1.56.0 (1)
AppVariant:          1:iPhone14,5:15
Code Type:           ARM-64 (Native)
Role:                Unspecified
Parent Process:      launchd [1]
Coalition:           com.locket.Locket.LocketWidget [3099]

Date/Time:           2024-01-31 18:38:49.2208 -0500
Launch Time:         2024-01-31 18:38:45.3753 -0500
OS Version:          iPhone OS 16.7.1 (20H30)
Release Type:        User
Baseband Version:    2.80.01
Report Version:      104

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

Triggered by Thread:  3


Thread 0 name:
Thread 0:
0   libswiftCore.dylib            	0x000000019ae07bc0 std::__1::__function::__func<getSuperclassMetadata::$_7, std::__1::allocator<getSuperclassMetadata::$_7>, swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess>... + 0 (function.h:334)
1   libswiftCore.dylib            	0x000000019ae158ec swift_getTypeByMangledNameImpl(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsi... + 1124 (MetadataLookup.cpp:1933)
2   libswiftCore.dylib            	0x000000019ae10d9c swift_getTypeByMangledName + 832 (CompatibilityOverrideRuntime.def:186)
3   libswiftCore.dylib            	0x000000019adf60bc getSuperclassMetadata + 252 (Metadata.cpp:3160)
4   libswiftCore.dylib            	0x000000019adf6440 _swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess, swift::TargetAnyClassMetadataObjCInterop<swift::InProcess> >*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout co... + 84 (Metadata.cpp:3221)
5   libswift_Concurrency.dylib    	0x00000001ab0c1078 type metadata completion function for _Deque._Storage._DequeBuffer + 44 (<compiler-generated>:0)
6   libswiftCore.dylib            	0x000000019adf2a1c _swift_getGenericMetadata(swift::MetadataRequest, void const* const*, swift::TargetTypeContextDescriptor<swift::InProcess> const*) + 1884 (Metadata.cpp:866)
7   libswift_Concurrency.dylib    	0x00000001ab0c5b10 __swift_instantiateGenericMetadata + 32 (<compiler-generated>:0)
8   libswift_Concurrency.dylib    	0x00000001ab0c50c8 partial apply for closure #2 in _Deque._Storage._ensure(minimumCapacity:) + 40 (<compiler-generated>:0)
9   libswift_Concurrency.dylib    	0x00000001ab0c5344 partial apply for closure #1 in _Deque._Storage.update<A>(_:) + 32
10  libswift_Concurrency.dylib    	0x00000001ab0c4f48 partial apply for closure #1 in _Deque._Storage.update<A>(_:) + 16
11  libswiftCore.dylib            	0x000000019aa76ea8 withUnsafeMutablePointer<A, B>(to:_:) + 28 (LifetimeManager.swift:82)
12  libswift_Concurrency.dylib    	0x00000001ab0b05e4 _Deque._Storage.update<A>(_:) + 268
13  libswift_Concurrency.dylib    	0x00000001ab0b0354 _Deque._Storage._ensure(minimumCapacity:) + 316 (Deque.swift:0)
14  libswift_Concurrency.dylib    	0x00000001ab0a87f4 _Deque.append(_:) + 96 (Deque.swift:399)
15  libswift_Concurrency.dylib    	0x00000001ab0a826c AsyncStream._Storage.yield(_:) + 1152 (AsyncStreamBuffer.swift:0)
16  libswift_Concurrency.dylib    	0x00000001ab0ac810 AsyncStream.Continuation.yield(_:) + 24 (AsyncStream.swift:196)
17  LocketWidgetExtension         	0x0000000102bbe49c closure #1 in implicit closure #1 in closure #1 in closure #2 in variable initialization expression of static AuthClient.liveValue + 188 (AuthClientLive.swift:0)
18  LocketWidgetExtension         	0x0000000102bbe518 thunk for @escaping @callee_guaranteed (@guaranteed FIRAuth, @guaranteed FIRUser?) -> () + 80 (<compiler-generated>:0)
19  LocketWidgetExtension         	0x00000001029a5130 __41-[FIRAuth addAuthStateDidChangeListener:]_block_invoke + 280 (FIRAuth.m:1674)
20  libdispatch.dylib             	0x00000001a81d2320 _dispatch_call_block_and_release + 32 (init.c:1518)
21  libdispatch.dylib             	0x00000001a81d3eac _dispatch_client_callout + 20 (object.m:560)
22  libdispatch.dylib             	0x00000001a81e26a4 _dispatch_main_queue_drain + 928 (queue.c:7794)
23  libdispatch.dylib             	0x00000001a81e22f4 _dispatch_main_queue_callback_4CF + 44 (queue.c:7954)
24  CoreFoundation                	0x00000001a0d97bb8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
25  CoreFoundation                	0x00000001a0d794f0 __CFRunLoopRun + 1992 (CFRunLoop.c:3147)
26  CoreFoundation                	0x00000001a0d7e37c CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
27  Foundation                    	0x000000019affaf74 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
28  Foundation                    	0x000000019affae08 -[NSRunLoop(NSRunLoop) run] + 64 (NSRunLoop.m:398)
29  libxpc.dylib                  	0x0000000200bba678 _xpc_objc_main + 496 (main.m:246)
30  libxpc.dylib                  	0x0000000200bbc924 xpc_main + 156 (init.c:1258)
31  Foundation                    	0x000000019b0428d0 -[NSXPCListener resume] + 312 (NSXPCListener.m:460)
32  ExtensionFoundation           	0x00000001ae342658 -[_EXRunningExtension resume] + 204 (EXRunningExtension.m:250)
33  ExtensionFoundation           	0x00000001ae3424f0 -[_EXRunningExtension startWithArguments:count:] + 188 (EXRunningExtension.m:228)
34  ExtensionFoundation           	0x00000001ae362520 EXExtensionMain + 220 (EXExtensionMain.m:31)
35  Foundation                    	0x000000019b086da0 NSExtensionMain + 204 (NSExtensionMain.m:21)
36  dyld                          	0x00000001c02bcdec start + 2220 (dyldMain.cpp:1165)

Thread 1:
0   libsystem_kernel.dylib        	0x00000001dfccb7dc __ulock_wait + 8
1   libsystem_platform.dylib      	0x0000000200ac6fb0 _os_unfair_lock_lock_slow + 176 (lock.c:578)
2   libswift_Concurrency.dylib    	0x00000001ab0a8a24 AsyncStream._Storage.next(_:) + 292 (AsyncStreamBuffer.swift:238)
3   libswift_Concurrency.dylib    	0x00000001ab08c4e0 withUnsafeContinuation<A>(_:) + 212 (PartialAsyncTask.swift:307)
4   libswift_Concurrency.dylib    	0x00000001ab0a9081 closure #2 in AsyncStream._Storage.next() + 1 (AsyncStreamBuffer.swift:259)
5   libswift_Concurrency.dylib    	0x00000001ab0c6835 partial apply for closure #2 in AsyncStream._Storage.next() + 1
6   libswift_Concurrency.dylib    	0x00000001ab0a376d withTaskCancellationHandler<A>(operation:onCancel:) + 1 (TaskCancellation.swift:50)
7   libswift_Concurrency.dylib    	0x00000001ab0a1f9d withTaskCancellationHandler<A>(operation:onCancel:) + 1 (<compiler-generated>:0)
8   libswift_Concurrency.dylib    	0x00000001ab0c6875 withTaskCancellationHandler<A>(handler:operation:) + 1
9   libswift_Concurrency.dylib    	0x00000001ab0a8e05 AsyncStream._Storage.next() + 1 (AsyncStreamBuffer.swift:256)
10  libswift_Concurrency.dylib    	0x00000001ab0c67f5 implicit closure #2 in implicit closure #1 in AsyncStream.init(_:bufferingPolicy:_:) + 1
11  libswift_Concurrency.dylib    	0x00000001ab0c67fd partial apply for implicit closure #2 in implicit closure #1 in AsyncStream.init(_:bufferingPolicy:_:) + 1
12  libswift_Concurrency.dylib    	0x00000001ab0ad635 AsyncStream.Iterator.next() + 1 (AsyncStream.swift:378)
13  libswift_Concurrency.dylib    	0x00000001ab0c67ed protocol witness for AsyncIteratorProtocol.next() in conformance AsyncStream<A>.Iterator + 1
14  libswift_Concurrency.dylib    	0x00000001ab09835d AsyncSequence.first(where:) + 1 (AsyncSequence.swift:289)
15  LocketWidgetExtension         	0x000000010286fa75 AsyncStream.first() + 1 (First.swift:7)
16  LocketWidgetExtension         	0x00000001027f72a1 Config.loadFirebase() + 1 (Config+Firebase.swift:48)
17  LocketWidgetExtension         	0x00000001027f2da9 LocketGenericProvider.getTimeline(configuration:kind:size:) + 1 (LocketGenericProvider.swift:44)
18  LocketWidgetExtension         	0x00000001027e9cc5 closure #1 in LocketIntentTimelineProvider.getTimeline(for:in:completion:) + 1 (LocketTimelineProviders.swift:44)
19  LocketWidgetExtension         	0x00000001027e9f89 partial apply for closure #1 in LocketIntentTimelineProvider.getTimeline(for:in:completion:) + 1 (<compiler-generated>:0)
20  LocketWidgetExtension         	0x000000010280d1f1 specialized thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A) + 1 (<compiler-generated>:0)
21  LocketWidgetExtension         	0x00000001027ea0f1 partial apply for specialized thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A) + 1 (<compiler-generated>:0)
22  libswift_Concurrency.dylib    	0x00000001ab0cedd9 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:496)

Thread 2:
0   libsystem_pthread.dylib       	0x0000000200b5db74 start_wqthread + 0 (:-1)

Thread 3 name:
Thread 3 Crashed:
0   libobjc.A.dylib               	0x0000000199d8fd68 objc_release + 16
1   libsystem_blocks.dylib        	0x0000000200b5a134 _call_dispose_helpers_excp + 48 (generic_helpers.c:30)
2   libsystem_blocks.dylib        	0x0000000200b59d64 _Block_release + 252 (runtime.cpp:1006)
3   LocketWidgetExtension         	0x00000001029a00fc __destroy_helper_block_e8_32s40s + 24 (FIRAuth.m:0)
4   libsystem_blocks.dylib        	0x0000000200b5a134 _call_dispose_helpers_excp + 48 (generic_helpers.c:30)
5   libsystem_blocks.dylib        	0x0000000200b59d64 _Block_release + 252 (runtime.cpp:1006)
6   LocketWidgetExtension         	0x00000001029a00fc __destroy_helper_block_e8_32s40s + 24 (FIRAuth.m:0)
7   libsystem_blocks.dylib        	0x0000000200b5a134 _call_dispose_helpers_excp + 48 (generic_helpers.c:30)
8   libsystem_blocks.dylib        	0x0000000200b59d64 _Block_release + 252 (runtime.cpp:1006)
9   libdispatch.dylib             	0x00000001a81d3eac _dispatch_client_callout + 20 (object.m:560)
10  libdispatch.dylib             	0x00000001a81db534 _dispatch_lane_serial_drain + 668 (queue.c:3885)
11  libdispatch.dylib             	0x00000001a81dc0d8 _dispatch_lane_invoke + 436 (queue.c:3976)
12  libdispatch.dylib             	0x00000001a81db40c _dispatch_lane_serial_drain + 372 (queue.c:3885)
13  libdispatch.dylib             	0x00000001a81dc0a4 _dispatch_lane_invoke + 384 (queue.c:3976)
14  libdispatch.dylib             	0x00000001a81e6cdc _dispatch_workloop_worker_thread + 648 (queue.c:6507)
15  libsystem_pthread.dylib       	0x0000000200b5dddc _pthread_wqthread + 288 (pthread.c:2618)
16  libsystem_pthread.dylib       	0x0000000200b5db7c start_wqthread + 8 (:-1)

Thread 4:
0   libsystem_pthread.dylib       	0x0000000200b5db74 start_wqthread + 0 (:-1)

Thread 5:
0   libsystem_pthread.dylib       	0x0000000200b5db74 start_wqthread + 0 (:-1)

Thread 6 name:
Thread 6:
0   libsystem_kernel.dylib        	0x00000001dfccaca4 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib        	0x00000001dfcddb74 mach_msg2_internal + 80 (mach_msg.c:201)
2   libsystem_kernel.dylib        	0x00000001dfcdde4c mach_msg_overwrite + 540 (mach_msg.c:0)
3   libsystem_kernel.dylib        	0x00000001dfccb1e8 mach_msg + 24 (mach_msg.c:323)
4   CoreFoundation                	0x00000001a0d77fb4 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2622)
5   CoreFoundation                	0x00000001a0d791e0 __CFRunLoopRun + 1208 (CFRunLoop.c:3005)
6   CoreFoundation                	0x00000001a0d7e37c CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
7   CFNetwork                     	0x00000001a1f696f0 +[__CFN_CoreSchedulingSetRunnable _run:] + 392 (CoreSchedulingSet.mm:1562)
8   Foundation                    	0x000000019b0144e4 __NSThread__start__ + 716 (NSThread.m:963)
9   libsystem_pthread.dylib       	0x0000000200b5e6b8 _pthread_start + 148 (pthread.c:893)
10  libsystem_pthread.dylib       	0x0000000200b5db88 thread_start + 8 (:-1)

Thread 7:
0   libsystem_pthread.dylib       	0x0000000200b5db74 start_wqthread + 0 (:-1)

Thread 8:
0   libsystem_pthread.dylib       	0x0000000200b5db74 start_wqthread + 0 (:-1)


Thread 3 crashed with ARM Thread State (64-bit):
    x0: 0x0000000135d13020   x1: 0x00000001036fde00   x2: 0x0000000000000000   x3: 0x0000000137a0daa0
    x4: 0x0000000000000080   x5: 0x0000000137a0daa0   x6: 0x0000000000000008   x7: 0x0000000000000000
    x8: 0x0000000000002b03   x9: 0x0000000000002b03  x10: 0x00000000000baba0  x11: 0x0000000000179f41
   x12: 0x0000000137a03f44  x13: 0x0000000000000007  x14: 0x0000000137a00000  x15: 0x000000005554b401
   x16: 0x0000000000000000  x17: 0x0000000137a21650  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x0000000137a1bf80  x21: 0x0000000000010000  x22: 0x0000000000000000  x23: 0x000000016d7e70e0
   x24: 0x0000000135d16418  x25: 0x0000000000000000  x26: 0x0000000000000114  x27: 0x0000000000000000
   x28: 0x0000000103d00980   fp: 0x000000016d7e6620   lr: 0x0000000200b5a134
    sp: 0x000000016d7e65f0   pc: 0x0000000199d8fd68     cpsr: 0x1000
   esr: 0x92000006 (Data Abort) byte read Translation fault


Binary Images:
        0x1027b8000 -         0x10335ffff LocketWidgetExtension arm64  <9dad5f4f043d3b52a86f14beb776f627> /private/var/containers/Bundle/Application/C94C7F7B-E082-48BC-A17F-70B56638CC35/Locket.app/PlugIns/LocketWidgetExtension.appex/LocketWidgetExtension
        0x10a844000 -         0x10a84ffff libobjc-trampolines.dylib arm64e  <c53d41c54cff3e4c952d5ccb73de95b2> /private/preboot/Cryptexes/OS/usr/lib/libobjc-trampolines.dylib
        0x199d8c000 -         0x199dcff3f libobjc.A.dylib arm64e  <1ff34faad6c3319bb651854379e9eadf> /usr/lib/libobjc.A.dylib
        0x19aa2c000 -         0x19af84fff libswiftCore.dylib arm64e  <6c016b5f38cc3c1d83b5996f6abb100c> /usr/lib/swift/libswiftCore.dylib
        0x19afb9000 -         0x19b896fff Foundation arm64e  <08587e68599130bba36237b31c21007e> /System/Library/Frameworks/Foundation.framework/Foundation
        0x1a0cff000 -         0x1a10e6fff CoreFoundation arm64e  <df935525036c30ae8d1d4e5f3dd7876a> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
        0x1a1d11000 -         0x1a20dbfff CFNetwork arm64e  <2b2a612a24ae37de915a5611c7ed46a5> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
        0x1a81d0000 -         0x1a8216fff libdispatch.dylib arm64e  <5c90fe9b7b3735e19e3e3baf6fda9ab0> /usr/lib/system/libdispatch.dylib
        0x1ab086000 -         0x1ab0e1ffb libswift_Concurrency.dylib arm64e  <93b1902617453710922b28645209ec40> /usr/lib/swift/libswift_Concurrency.dylib
        0x1ae340000 -         0x1ae3a3fff ExtensionFoundation arm64e  <3a78593f03423b5f81e759823f39d8e0> /System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation
        0x1c02a7000 -         0x1c032ca53 dyld arm64e  <87696a8fb77839008aaa05aa4864f4b5> /usr/lib/dyld
        0x1dfcca000 -         0x1dfd01ff7 libsystem_kernel.dylib arm64e  <37db07453b173ef6baeff49bb05081ce> /usr/lib/system/libsystem_kernel.dylib
        0x200ac6000 -         0x200accff7 libsystem_platform.dylib arm64e  <35e53dc88bad3e39bbbad6d1fbeb6361> /usr/lib/system/libsystem_platform.dylib
        0x200b58000 -         0x200b5cff8 libsystem_blocks.dylib arm64e  <efa9bf057753377f8ed2bd332a51500c> /usr/lib/system/libsystem_blocks.dylib
        0x200b5d000 -         0x200b68ff3 libsystem_pthread.dylib arm64e  <41a466671d073fc097150f5990b8757f> /usr/lib/system/libsystem_pthread.dylib
        0x200ba0000 -         0x200be1fff libxpc.dylib arm64e  <d9b20951e3173600b77cf076b8dc0c12> /usr/lib/system/libxpc.dylib

EOF

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

{
  "pins" : [
    {
      "identity" : "firebase-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/firebase-ios-sdk.git",
      "state" : {
        "revision" : "f91c8167141d0279726c6f6d9d4a47c026785cbc",
        "version" : "10.21.0"
      }
    }
  ],
  "version" : 2
}


If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

Replace this line with the contents of your Podfile.lock!

bryansum avatar Feb 09 '24 23:02 bryansum

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

google-oss-bot avatar Feb 09 '24 23:02 google-oss-bot

Thanks for the detailed report and analysis. We'll investigate. In the meantime a reproduction would be really helpful.

paulb777 avatar Feb 12 '24 19:02 paulb777

Any update on this?

jesus-mg-ios avatar Mar 23 '24 14:03 jesus-mg-ios

Does this still occur with Firebase 11.x?

paulb777 avatar Aug 05 '24 18:08 paulb777

Hey @bryansum. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Aug 12 '24 01:08 google-oss-bot