My iOS app displays a gallery of thumbnails in a tableView (four to a row).  To 
allow smooth scrolling, I lazy-load the image data on a background thread using 
dispatch_async().

sqlite3_threadsafe() returns true.
sqlite3_open_v2() uses SQLITE_OPEN_FULLMUTEX.
queue is a serial queue from dispatch_queue_create(...).
There is only one connection to the database.

lazy load summary logic:
   dispatch_async(queue, ^{
        done once:  sqlite3_prepare_v2( "SELECT ..." ... );

        sqlite3_bind_int(...);
        sqlite3_bind_int(...);
        sqlite3_step();   // occasionally crashes here (showing ESC_BAD_ACCESS 
on main thread)
        ... sqlite3_column_blob(...);
        ... sqlite3_column_bytes(...);
        // ...
        // occasionally crashes here (showing ESC_BAD_ACCESS on main thread) 
not inside SQLite
        // ...
        sqlite3_reset();
   });

The main thread is not doing anything with the DB when the crash occurs (it has 
previously loaded an array with all the id values needed for the lazy-load's 
SELECT statement).  It doesn't crash very often (might take 10, 20 or 30 
trials), but when it happens, it crashes while loading one of the first few 
thumbnails.

It's not a zombie object issue (tested with NSZombieEnabled).

Any ideas on how to debug this?

Jeff


Reply via email to