ccgus / fmdb

A Cocoa / Objective-C wrapper around SQLite
Other
13.84k stars 2.77k forks source link

crash sqlite3 #767

Open Max-Job opened 4 years ago

Max-Job commented 4 years ago

Good day In my project on objective c, crashes began to appear in sqlite3 on ios 13.2.3 and later devices. I use the latest version of FMDB / standalone. Maybe you have ideas, what could be the problem?

EXC_BAD_ACCESS columnNameForIndex: > objectForColumnIndex: > qL9١! > Attempted to dereference garbage pointer 0x10508ea60.

sqlite3 +0x017e98 sqlite3DbFreeNN sqlite3.c:26936
sqlite3 +0x026950 releaseMemArray sqlite3.c:65535
sqlite3 +0x005738 sqlite3VdbeClearObject sqlite3.c:65535
sqlite3 +0x026c00 sqlite3VdbeDelete sqlite3.c:65535
sqlite3 +0x00c294 sqlite3VdbeFinalize sqlite3.c:65535
sqlite3 +0x00c138 vdbeSafety sqlite3.c:65535
sqlite3 +0x00c104 sqlite3_finalize sqlite3.c:65535
FMDB +0x009d94 -[FMStatement close] FMDatabase.m:1655
FMDB +0x009d44 -[FMStatement dealloc] FMDatabase.m:1646
FMDB +0x00d170 -[FMResultSet close] FMResultSet.m:59
FMDB +0x00d9e4 -[FMResultSet nextWithError:] FMResultSet.m:209
GasEngineerSoftware +0x0a4e00 -[DBConnection fetchRecords:] DBConnection.m:114
- (NSMutableArray *)fetchRecords:(NSString *)query {
    FUNCTION_START;

    if (LOGS_ON) NSLog(@"Select Query : %@", query);

    NSMutableArray *recordArray = [NSMutableArray array];

    BOOL isExecuted = false;

    FMResultSet *res = [_db executeQuery:query];

    if (res) {
        isExecuted = true;

        while ([res next]) {
            NSInteger cnt = [res columnCount];
            NSMutableDictionary *row = [NSMutableDictionary dictionary];

            for (int i = 0; i < cnt; ++i) {
                [row setObject:[NSString stringWithFormat:@"%@", [res objectForColumnIndex:i]] forKey:[res columnNameForIndex:i]];
            }

            if (row)
                [recordArray addObject:row];
        }
    }

    if (!isExecuted && query)
        [self performSelectorInBackground:@selector(sendApplog:) withObject:@{ApplogQuery: query}];

    FUNCTION_END;

    return recordArray;
}

executeQuery:

- (FMResultSet *)executeQuery:(NSString*)sql, ... {
    va_list args;
    va_start(args, sql);

    id result = [self executeQuery:sql withArgumentsInArray:nil orDictionary:nil orVAList:args];

    va_end(args);
    return result;
}
ryanstout commented 4 years ago

@Max-Job did you ever find out a solution? We're seeing the same thing with a different sqlite wrapper library.