3

I have a problem with an app developed using Xcode. It runs well in Debug but crashes in Release on a SQLite statement:

if (sqlite3_prepare_v2(database, sql, -1, &init_statement, NULL) != SQLITE_OK) {
NSAssert1(NO, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
}
if (sqlite3_step(init_statement) == SQLITE_ROW) {
... }

In Release mode it crashed at the line sqlite3_step(init_statement) == SQLITE_ROW with this error:

Program received signal: "EXC_BAD_ACCESS".

The following is the message I got before crashing:

[Switching to process 7939 thread 0x1f03]

There is no problem found in Debug mode.

Thanks for any help!

yuji
  • 16,695
  • 4
  • 63
  • 64
huan
  • 31
  • 1
  • How are you setting `init_statement`? – jrtc27 Feb 01 '12 at 22:31
  • Sounds like compiler optimizations might be exposing a previously hidden bug. Does the static analyzer issue any warnings? – Conrad Shultz Feb 01 '12 at 22:44
  • sqlite3_stmt *init_statement = nil; – huan Feb 02 '12 at 02:35
  • After Analyze, 26 messages were issued in sqlite3.c, including some "Dead store"s and "Logic error"s with "Switch Branch" Badges. sqlite3.c is with a "question mark" badge under a sub-project of my current project. I thought sqlite3.c is okay since it was not changed. Do those messages matter? – huan Feb 02 '12 at 03:14
  • This is resolved by turning off the compiler's optimization of a sub-project. Not so sure about the reason. – huan Feb 14 '12 at 06:19
  • Hello Huan, I am also stucked in same issue as above. Can you suggest me any solution in brief. Thanks. – Rajan Maharjan Apr 10 '13 at 07:02

0 Answers0