firebase-ios-sdk: com.google.fira.worker crashing on executeSQLStatement:error:

Describe your environment

  • Xcode version: 11.2
  • Firebase SDK version: 6.12.0
  • Firebase Component: Analytics
  • Component version: Unknown

Describe the problem

Crashlytics is reporting that com.google.fira.worker is crashing my application. This is by far the most popular crash so I am wondering if it is indeed the Analytics framework that is crashing or it just another part of my application.

Steps to reproduce:

Have not gotten the error to occur myself, but it shows frequently on my Crashlytics dashboard so I have several stack traces.

Here is the thread that Crashlytics blamed:

Crashed: com.google.fira.worker
0  libsystem_platform.dylib       0x225733108 <redacted> + 36
1  libsystem_platform.dylib       0x2257333c4 <redacted> + 148
2  libsqlite3.dylib               0x225fe027c sqlite3_rekey + 776
3  libsqlite3.dylib               0x225f30c04 sqlite3_snprintf + 3200
4  libsqlite3.dylib               0x225f30800 sqlite3_snprintf + 2172
5  libsqlite3.dylib               0x225f93bec sqlite3_free_table + 49624
6  libsqlite3.dylib               0x225ff457c sqlite3_rekey + 83464
7  libsqlite3.dylib               0x225ff4268 sqlite3_rekey + 82676
8  libsqlite3.dylib               0x225f966b4 sqlite3_free_table + 60576
9  libsqlite3.dylib               0x225f71c68 sqlite3_step + 29608
10 libsqlite3.dylib               0x225f6aa80 sqlite3_step + 448
11 Zebra                          0x10077fb98 -[APMSqliteStore executeSQLStatement:error:] + 4371430296
12 Zebra                          0x10077dfd0 -[APMSqliteStore updateRecord:inTableWithName:columnName:columnValue:error:] + 4371423184
13 Zebra                          0x100748e74 -[APMDatabase updateDataType:inTableWithName:columnName:columnValue:error:createDictionaryBlock:] + 4371205748
14 Zebra                          0x100754edc __42-[APMMeasurement writeEventOnWorkerQueue:]_block_invoke.1219 + 4371255004
15 Zebra                          0x10077f1b0 -[APMSqliteStore performTransaction:] + 4371427760
16 Zebra                          0x100754148 -[APMMeasurement writeEventOnWorkerQueue:] + 4371251528
17 Zebra                          0x1007537e0 -[APMMeasurement handleEventOnWorkerQueue:] + 4371249120
18 Zebra                          0x1007688a4 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 4371335332
19 libdispatch.dylib              0x22553c308 <redacted> + 32
20 libdispatch.dylib              0x22553d888 <redacted> + 20
21 libdispatch.dylib              0x225544dd4 <redacted> + 552
22 libdispatch.dylib              0x225545918 <redacted> + 364
23 libdispatch.dylib              0x22554dcc0 <redacted> + 588
24 libsystem_pthread.dylib        0x225739a98 _pthread_wqthread + 308
25 libsystem_pthread.dylib        0x22573fdc4 start_wqthread + 4

Here is the thread that my application was running on:

com.apple.main-thread
0  libsqlite3.dylib               0x225f79464 sqlite3_step + 60324
1  libsqlite3.dylib               0x225f6aa80 sqlite3_step + 448
2  Zebra                          0x1006bfe3c -[ZBDatabaseManager packagesFromRepo:inSection:numberOfPackages:startingAt:] + 718 (ZBDatabaseManager.m:718)
3  Zebra                          0x10067a314 __44-[ZBChangesTableViewController refreshTable]_block_invoke + 195 (ZBChangesTableViewController.m:195)
4  libdispatch.dylib              0x22553c308 <redacted> + 32
5  libdispatch.dylib              0x22553d888 <redacted> + 20
6  libdispatch.dylib              0x22554973c _dispatch_main_queue_callback_4CF + 1012
7  CoreFoundation                 0x225abe734 <redacted> + 16
8  CoreFoundation                 0x225ab93e4 <redacted> + 1888
9  CoreFoundation                 0x225ab8964 CFRunLoopRunSpecific + 452
10 GraphicsServices               0x227cf9d8c GSEventRunModal + 108
11 UIKitCore                      0x252f55758 UIApplicationMain + 216
12 Zebra                          0x100677cb8 main + 14 (main.m:14)
13 libdyld.dylib                  0x225574fd8 <redacted> + 4

Crashlytics also gives me the following information in the “Keys” section:

BUG IN CLIENT OF LIBPLATFORM: Unlock of an os_unfair_lock not owned by current thread

Relevant Code:

Here is the method -[ZBDatabaseManager packagesFromRepo:inSection:numberOfPackages:startingAt:] from the stack trace above. Line 718 is the while loop while (sqlite3_step(statement) == SQLITE_ROW)

- (NSArray <ZBPackage *> *)packagesFromRepo:(ZBRepo * _Nullable)repo inSection:(NSString * _Nullable)section numberOfPackages:(int)limit startingAt:(int)start {
    if ([self openDatabase] == SQLITE_OK) {
        NSMutableArray *packages = [NSMutableArray new];
        NSString *query;
        
        if (section == NULL) {
            NSString *repoPart = repo ? [NSString stringWithFormat:@"WHERE REPOID = %d", [repo repoID]] : @"WHERE REPOID > 0";
            query = [NSString stringWithFormat:@"SELECT * FROM PACKAGES %@ ORDER BY LASTSEEN DESC LIMIT %d OFFSET %d", repoPart, limit, start];
        } else {
            NSString *repoPart = repo ? [NSString stringWithFormat:@"AND REPOID = %d", [repo repoID]] : @"AND REPOID > 0";
            query = [NSString stringWithFormat:@"SELECT * FROM PACKAGES WHERE SECTION = '\%@\' %@ LIMIT %d OFFSET %d", section, repoPart, limit, start];
        }
        
        sqlite3_stmt *statement;
        if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) {
            while (sqlite3_step(statement) == SQLITE_ROW) {
                ZBPackage *package = [[ZBPackage alloc] initWithSQLiteStatement:statement];
                
                [packages addObject:package];
            }
        } else {
            [self printDatabaseError];
        }
        sqlite3_finalize(statement);
        [self closeDatabase];
        
        return [self cleanUpDuplicatePackages:packages];
    }
    [self printDatabaseError];
    return NULL;
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (13 by maintainers)

Most upvoted comments

Looks like that was the issue, all crashes related to APMSqliteStore (endTransaction was also another crash I saw) seem to no longer be happening. I do still get logs for them and I check them but every log I have gotten so far has been from a user who has not updated to the fix yet.

I’ve commented out the shutdown method and pushed a build of it out. I’ll keep track of the crash logs over the next day and see if they trend downward.

Updated the Analytics docs (internal change: cr/280485745). The changes will be reflected in the headers and reference documentation of the next Analytics release.

Thanks for reporting this bug!