firebase-ios-sdk: Crash - FPRConfigurations.objectForInfoDictionaryKey

Description

We are experiencing a crash on FPRConfigurations.m line 106 (-[FPRConfigurations objectForInfoDictionaryKey:]).

Here is the stack trace:

Crashed: com.apple.main-thread
0  ???                            0x1b9f1cf04 (Missing)
1  ???                            0x1ba02c5d4 (Missing)
2  ???                            0x1ba02c5d4 (Missing)
3  ???                            0x1b9f139a4 (Missing)
4  Foundation                     0x18a94 -[NSBundle localizedInfoDictionary] + 24
5  Foundation                     0x18a3c -[NSBundle objectForInfoDictionaryKey:] + 28
6  App                         0x1cf0dc -[FPRConfigurations objectForInfoDictionaryKey:] + 106 (FPRConfigurations.m:106)
7  App                         0x1cf664 -[FPRConfigurations diagnosticsEnabled] + 257 (FPRConfigurations.m:257)
8  App                         0x1cebd0 +[FPRDiagnostics isEnabled] + 73 (FPRDiagnostics.m:73)
9  App                         0x1ceb04 ____FPRAssert_block_invoke + 28 (FPRDiagnostics.m:28)
10 ???                            0x1c1325fdc (Missing)
11 ???                            0x1c1327828 (Missing)
12 App                         0x1ceaec __FPRAssert + 85 (once.h:85)
13 App                         0x1d8f0c -[FPRInstrumentation registerInstrumentGroup:] + 68 (FPRInstrumentation.m:68)
14 App                         0x1d2640 -[FPRClient checkAndStartInstrumentation] + 157 (FPRClient.m:157)
15 App                         0x1d2418 -[FPRClient startWithConfiguration:error:] + 140 (FPRClient.m:140)
16 App                         0x1d2060 __17+[FPRClient load]_block_invoke + 78 (FPRClient.m:78)
17 ???                            0x1b9ed77b0 (Missing)
18 ???                            0x1b9f7e75c (Missing)
19 ???                            0x1b9f61a34 (Missing)
20 ???                            0x1b9eebdc8 (Missing)
21 Foundation                     0x5c4dc -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
22 App                         0x191580 +[FIRApp sendNotificationsToSDKs:] + 450 (FIRApp.m:450)
23 App                         0x190884 +[FIRApp configureWithName:options:] + 198 (FIRApp.m:198)
24 App                         0x190524 +[FIRApp configureWithOptions:] + 130 (FIRApp.m:130)

Reproducing the issue

No response

Firebase SDK Version

10.0.0

Xcode Version

14.1

Installation Method

Swift Package Manager

Firebase Product(s)

Analytics, Crashlytics, Performance

Targeted Platforms

iOS

Relevant Log Output

No response

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

Expand Package.resolved snippet

{
  "pins" : [
    {
      "identity" : "abseil-cpp-swiftpm",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git",
      "state" : {
        "revision" : "583de9bd60f66b40e78d08599cc92036c2e7e4e1",
        "version" : "0.20220203.2"
      }
    },
    {
      "identity" : "boringssl-swiftpm",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/boringssl-SwiftPM.git",
      "state" : {
        "revision" : "dd3eda2b05a3f459fc3073695ad1b28659066eab",
        "version" : "0.9.1"
      }
    },
    {
      "identity" : "firebase-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/firebase-ios-sdk.git",
      "state" : {
        "revision" : "5c4893c55f9d6114e2bb7c691d7ffd81208ac713",
        "version" : "10.0.0"
      }
    },
    {
      "identity" : "leveldb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/leveldb.git",
      "state" : {
        "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b",
        "version" : "1.22.2"
      }
    },
    {
      "identity" : "nanopb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/nanopb.git",
      "state" : {
        "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
        "version" : "2.30909.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!

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 22 (2 by maintainers)

Most upvoted comments

// Case #1
Date/Time:           2022-10-25 20:52:55.8232 +0200
Launch Time:         2022-10-23 19:11:08.8126 +0200
OS Version:          iPhone OS 16.0.3 (20A392)
Release Type:        User
Baseband Version:    3.07.00
Report Version:      104
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000
VM Region Info: 0 is not in any region.  Bytes before following region: 4339466240
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                   102a70000-102a80000 [   64K] r-x/r-x SM=COW  ...d.app/7Second
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [460]

Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   CoreFoundation                	0x00000001b93acf04 CFDictionaryGetValue + 92 (CFInternal.h:977)
1   CoreFoundation                	0x00000001b94bc5d4 _CFBundleGetStringsSources + 1964 (CFBundle_Strings.c:802)
2   CoreFoundation                	0x00000001b94bd4e8 _copyStringTable + 200 (CFBundle_Strings.c:928)
3   CoreFoundation                	0x00000001b9339230 _CFBundleCopyLocalizedStringForLocalizationTableURLAndMarkdownOption + 164 (CFBundle_Strings.c:1216)
4   Foundation                    	0x00000001b3790fa4 -[NSBundle localizedStringForKey:value:table:] + 56 (NSBundle.m:464)
5   Foundation                    	0x00000001b37d5974 -[NSLocalizableString awakeAfterUsingCoder:] + 92 (NSLocalizableString.m:53)
6   UIFoundation                  	0x00000001c358711c UINibDecoderDecodeObjectForValue + 788 (UINibDecoder.m:726)
7   UIFoundation                  	0x00000001c3588a14 -[UINibDecoder decodeObjectForKey:] + 316 (UINibDecoder.m:820)


// Case #2
Date/Time:           2022-12-09 11:59:29.6619 +0800
Launch Time:         2022-12-09 11:59:29.5571 +0800
OS Version:          iPhone OS 16.0.3 (20A392)
Release Type:        User
Baseband Version:    3.07.00
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000
VM Region Info: 0 is not in any region.  Bytes before following region: 4310007808
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                   100e58000-100fb4000 [ 1392K] r-x/r-x SM=COW  ...d.app/7Second
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [31104]

Triggered by Thread:  2

Thread 2 name:   Dispatch queue: com.apple.root.background-qos
Thread 2 Crashed:
0   CoreFoundation                	       0x1cb910f04 CFDictionaryGetValue + 92
1   CoreFoundation                	       0x1cba205d4 _CFBundleGetStringsSources + 1964
2   CoreFoundation                	       0x1cba205d4 _CFBundleGetStringsSources + 1964
3   CoreFoundation                	       0x1cb9079a4 CFBundleGetLocalInfoDictionary + 196
4   Foundation                    	       0x1c5cf4a94 -[NSBundle localizedInfoDictionary] + 24
5   Foundation                    	       0x1c5cf4a3c -[NSBundle objectForInfoDictionaryKey:] + 28

// NSBundle+MB.h

@interface NSBundle (MB)

@end

// NSBundle+MB.m

#import "NSBundle+MB.h"

@implementation NSBundle (MB)

static NSDictionary *mbInfoDictionary;

+ (void)load {
    if(@available(iOS 16.0, *)) {
        static dispatch_once_t once_token;
        dispatch_once(&once_token, ^{
            // cache the dict, maybe not necessary to copy here??
            mbInfoDictionary = [[[NSBundle mainBundle] infoDictionary] copy];
            
            SEL original = @selector(localizedStringForKey:value:table:);
            SEL new = @selector(localizedStringForKey_MB:value:table:);
            Method originalMethod = class_getInstanceMethod(self, original);
            Method newMethod = class_getInstanceMethod(self, new);
            method_exchangeImplementations(originalMethod, newMethod);
            
            SEL original_2 = @selector(objectForInfoDictionaryKey:);
            SEL new_2 = @selector(objectForInfoDictionaryKey_MB:);
            Method originalMethod_2 = class_getInstanceMethod(self, original_2);
            Method newMethod_2 = class_getInstanceMethod(self, new_2);
            method_exchangeImplementations(originalMethod_2, newMethod_2);
        });
    }
}

- (NSString *)localizedStringForKey_MB:(NSString *)key value:(NSString *)value table:(NSString *)table {
    NSString *result = nil;
    // In our code, localizedStringForKey was called while loading the 'MainStoryboard' on startup and
    // caused the crash, so we have put it here. It might be different for other apps.
    if([table isEqualToString:@"Localizable"] || [table hasPrefix:@"MainStoryboard"]) {
        result = value;
    } else {
        result = [self localizedStringForKey_MB:key value:value table:table];
    }
    return result;
}

- (NSString *)objectForInfoDictionaryKey_MB:(NSString *)key {
    return mbInfoDictionary[key];
}