0

I am doing a lot of inserts in my sqlite db. For some reason, at a specific point, the app crashes. I checked the insert command - everything is fine. If I run it on an iPhone 4 device - it runs perfectly.

The problem is that I don't get any error messages, not even memory warnings. xCode seems to still run, but on the device, the app crashes.

This is my code:

    sqlite3_stmt *compiledStatement;
    for (UpdateItems *one in arrList) {
        NSString *stat;
        stat = [[NSString alloc] initWithFormat:@"insert into table values (null, (select id from t1 where code='%@'), (select id from t2 where c='%@'), '%@', '%@', '%@', '%@', '%@', '%@')", one.bk, one.code, one.data, one.b, one.bV, one.s, one.sV, one.o];
        if(sqlite3_prepare_v2(database, [stat UTF8String], -1, &compiledStatement, NULL) == SQLITE_OK)
        {
            while(YES){
                NSInteger result = sqlite3_step(compiledStatement);
                printf("db error: %s\n", sqlite3_errmsg(database)); 
                if(result == SQLITE_DONE){
                    index = index + 1;
                    double totalPrc = 0.75f + roundf(((double) index / totalRecords) / (100 / 20) * 100.0f) / 100.0f;
                    if (self.percentageCompleted != totalPrc) {
                        self.percentageCompleted = totalPrc;
                        [self performSelectorOnMainThread:@selector(refreshHUD) withObject:nil waitUntilDone:NO];
                    }
                    break;
                }
                else if(result != SQLITE_BUSY){
                    printf("db error: %s\n", sqlite3_errmsg(database)); 
                    break;
                }
            }
            sqlite3_reset(compiledStatement);
        }
        [stat release];
    }

How can I track this, to see what is the problem?

CristiC
  • 22,068
  • 12
  • 57
  • 89
  • You might not see anything on xcode console, what about device crash logs ? Whenever there is a crash, crash reporter generates a crash report. Use XCode organizer to bring up device logs, symbolicate them. – 0x8badf00d Nov 12 '11 at 14:14
  • @0x8badf00d: Yes, indeed. In the device logs I found that there is a memory error. Thanks for the suggestion. Place an answer so I can accept it. – CristiC Nov 12 '11 at 14:51
  • @Parkyprg Iam aslo facing the same problem, could you please tell me how did you solve your problem? – Manish Agrawal Jan 25 '12 at 10:52
  • @Passionate - I have checked in the device logs. I saw the crash there. – CristiC Jan 25 '12 at 17:41
  • @Parkyprg I dont have device logs as the app is crashing on client's app. could you please tell the exact problem you found using your device logs.As I am aslo inserting the data in database. – Manish Agrawal Jan 25 '12 at 17:46
  • @Passionate - In my case, I was inserting a duplicate primary key - after that, the database got locked and this was the reason for crashing. If you have placed some messages in cases of database error, you can ask your client to send you the device logs for your application. – CristiC Jan 26 '12 at 12:53

2 Answers2

1

You might not see anything on xcode console, what about device crash logs ? Whenever there is a crash, crash reporter generates a crash report. Use XCode organizer to bring up device logs, symbolicate them

0x8badf00d
  • 6,391
  • 3
  • 35
  • 68
1

If the App that crashed was built with: stripping debug symbols - NO:

a nice symbolicated crash log should appear in your organizer window giving a stack trace, etc:

chown
  • 51,908
  • 16
  • 134
  • 170