Skip to content

Intermittent crash in FUtilities.intForString #9096

Closed
@softwaresaiyajin

Description

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 13.0
  • Firebase SDK version:8.9.1
  • Installation method: Swift Package Manager
  • Firebase Component: Database
  • Target platform(s): iOS

[REQUIRED] Step 2: Describe the problem

  • It appeared when we started using the SDK as dependency of one of our SPM package, before, we were using cocoapods and it was fine.
  • FirebaseDatabase entities get mapped when app is launched and it intermittently crashes in FUtilities.intForString

Steps to reproduce:

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

  • Happens when we launch the app since we starting mapping entities immediately
  • Attached (crashlog.txt) is the crash report

If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.

Relevant Code:

// TODO(you): code here to reproduce the problem
+ (NSNumber *)intForString:(NSString *)string {
    static NSCharacterSet *notDigits = nil;
    if (!notDigits) {
        notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
    }
    if ([string rangeOfCharacterFromSet:notDigits].length == 0) {
        NSInteger num;
        NSScanner *scanner = [NSScanner scannerWithString:string];
        if ([scanner scanInteger:&num]) {
            return [NSNumber numberWithInteger:num];
        }
    }
    return nil;
}

Screen Shot 2021-12-14 at 11 11 55 AM
crashlog.txt

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions