1eeb8424157d20ff6eaf2118a026360a0af4160e
4 Nisan 2024

Nanopb + Firebase Version Crash [Swift]

ile umut
CleanShot 2024 04 04 at 12.48.59@2x

Paket yöneticisindeki Firebase versiyonum ve ios 17.2 ile yaşadığım crash’i araştırdığımda, Firebase kütüphanesiyle alakalı bir sorun olduğunu buldum ve paylaşmak istedim.

Crash raporunu

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000001727c0ffc
Exception Codes: 0x0000000000000001, 0x00000001727c0ffc
VM Region Info: 0x1727c0ffc is not in any region.  Bytes after previous region: 48664573  Bytes before following region: 226750468
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      Stack                       16f8d0000-16f958000    [  544K] rw-/rwx SM=PRV  thread 13
--->  GAP OF 0x106a8000 BYTES
      unused __TEXT               180000000-180058000    [  352K] r-x/rwx SM=COW  unused  unknown system shared lib __TEXT
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [4595]

Triggered by Thread:  0

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   SimpleAI                      	       0x100d1d4a4 safe_read_bool + 0 (pb_encode.c:140) [inlined]
1   SimpleAI                      	       0x100d1d4a4 pb_enc_bool + 0 (pb_encode.c:771)
2   SimpleAI                      	       0x100d1cecc encode_basic_field + 256 [inlined]
3   SimpleAI                      	       0x100d1cecc encode_field + 436 (pb_encode.c:457)
4   SimpleAI                      	       0x100d1ccec pb_encode + 172 (pb_encode.c:544)
5   SimpleAI                      	       0x100d5eee4 FIRSESEncodeProto + 64 (FIRSESNanoPBHelpers.m:60)
6   SimpleAI                      	       0x100d709b4 SessionStartEvent.transportBytes() + 232 (SessionStartEvent.swift:155)
7   SimpleAI                      	       0x100d70c3c @objc SessionStartEvent.transportBytes() + 28
8   SimpleAI                      	       0x100d0e39c -[GDTCOREvent setDataObject:] + 68 (GDTCOREvent.m:101)
9   SimpleAI                      	       0x100d69e24 EventGDTLogger.logEvent(event:completion:) + 108 (EventGDTLogger.swift:43)
10  SimpleAI                      	       0x100d69fe8 protocol witness for EventGDTLoggerProtocol.logEvent(event:completion:) in conformance EventGDTLogger + 20
11  SimpleAI                      	       0x100d6fcc0 closure #1 in SessionCoordinator.attemptLoggingSessionStart(event:callback:) + 176 (SessionCoordinator.swift:47)
12  SimpleAI                      	       0x100d6fec0 closure #1 in SessionCoordinator.fillInFIID(event:callback:) + 180
13  SimpleAI                      	       0x100d6eacc closure #1 in FIRInstallations.installationID(completion:) + 32 [inlined]
14  SimpleAI                      	       0x100d6eacc partial apply for closure #1 in FIRInstallations.installationID(completion:) + 48
15  SimpleAI                      	       0x100d6e990 thunk for @escaping @callee_guaranteed (@guaranteed String?, @guaranteed Error?) -> () + 96
16  SimpleAI                      	       0x100cf5a20 __49-[FIRInstallations installationIDWithCompletion:]_block_invoke + 56 (FIRInstallations.m:201)
17  SimpleAI                      	       0x100cecf24 __56-[FBLPromise chainOnQueue:chainedFulfill:chainedReject:]_block_invoke.33 + 52 (FBLPromise.m:273)
18  libdispatch.dylib             	       0x18016b4f4 _dispatch_call_block_and_release + 24
19  libdispatch.dylib             	       0x18016cd3c _dispatch_client_callout + 16
20  libdispatch.dylib             	       0x18017bb60 _dispatch_main_queue_drain + 1332
21  libdispatch.dylib             	       0x18017b61c _dispatch_main_queue_callback_4CF + 40
22  CoreFoundation                	       0x1803f1a30 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
23  CoreFoundation                	       0x1803ec148 __CFRunLoopRun + 1936
24  CoreFoundation                	       0x1803eb5a4 CFRunLoopRunSpecific + 572
25  GraphicsServices              	       0x18e9fbae4 GSEventRunModal + 160
26  UIKitCore                     	       0x1852f02e4 -[UIApplication _run] + 868
27  UIKitCore                     	       0x1852f3f5c UIApplicationMain + 124
28  SwiftUI                       	       0x1c51fc1b0 0x1c4371000 + 15249840
29  SwiftUI                       	       0x1c51fc050 0x1c4371000 + 15249488
30  SwiftUI                       	       0x1c4f02fa4 0x1c4371000 + 12132260
31  SimpleAI                      	       0x100c1d2dc static SimplyAIApp.$main() + 52 [inlined]
32  SimpleAI                      	       0x100c1d2dc main + 64
33  dyld_sim                      	       0x101ee9544 start_sim + 20
34  dyld                          	       0x10206a0e0 start + 2360

Nanopb + Firebase Version Crash’inin Çözümü

Görüldüğü üzere Firebase bir boolean değişken bekliyor ancak nanopb kütüphanesinde bir sorun ile karşılaşarak crash oluyor. Bu bug Firebase 10.22.0 ve üzerinde fixlenmiş görünüyor ki spm’den Firebase paketimi güncellediğimde artık sorunla karşılaşmadım.

Sorunu araştırıp bulduğum stackoverflow kaynağı ise: https://stackoverflow.com/a/78122992/4300071