[sqlite] ESC_BAD_ACCESS when using a background thread

2015-09-02 Thread Jeffrey Mattox
>> On Sep 1, 2015, at 9:37 AM, Roger Binns wrote: >> >> On 08/31/2015 11:28 PM, Jeff M wrote: >> All my bad -- I'm fessing up. > > Can you tell us how you found the root causes of the problems? It > would be nice to know what tools and techniques worked. > Roger Since you asked... The crash

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-09-01 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/31/2015 11:28 PM, Jeff M wrote: > All my bad -- I'm fessing up. Can you tell us how you found the root causes of the problems? It would be nice to know what tools and techniques worked. Roger -BEGIN PGP SIGNATURE- Version: GnuPG v2

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-09-01 Thread Jeff M
I'm the OP, just closing the loop on this thread. I solved the crashing and the memory allocation issues. The crashing was due to NSMutableDictionary not being thread safe (can't do setObject:forKey on a background thread). The memory allocation issue (memory kept increasing) was due to a

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-25 Thread Simon Slavin
On 25 Aug 2015, at 6:23pm, Roger Binns wrote: > Generally you would be better off using something like homebrew: > > http://brew.sh/ > > [snip] > > Instruments isn't too bad, but IIRC does not do the same thing as > valgrind. Instruments is a lighter less thorough functionality. > Simon

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-25 Thread Simon Slavin
On 25 Aug 2015, at 10:38am, Jeff M wrote: > Looking at Xcode's memory report (and using Instruments), I see that memory > does ratchet up, despite my being very careful matching alloc/releases (this > app is pre-ARC). I need to relearn Instruments. You were tricked. You don't need to

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-25 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/25/2015 02:38 AM, Jeff M wrote: > I tried to install valgrind (on Mac OS Yosemite), but I can't get > it to compile. I don't have the fortitude to work out the install > issues. Generally you would be better off using something like homebrew:

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-25 Thread Jeff M
On Aug 24, 2015, at 11:50 AM, Roger Binns wrote: > On 08/24/2015 03:08 AM, Jeff M wrote: >> I've checked all of your suggestions and nothing is amiss. > > You ran valgrind and it said everything is fine? That would be shocking. You caught me. I wasn't familiar with valgrind, so I passed over

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-24 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/24/2015 03:08 AM, Jeff M wrote: > I've checked all of your suggestions and nothing is amiss. You ran valgrind and it said everything is fine? That would be shocking. > I don't understand how the main thread can run before the > background

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-24 Thread Jeff M
Simon, Roger: I've checked all of your suggestions and nothing is amiss. The background thread fetches the image data and caches it by adding the data to an NSMutableDictionary. The main thread checks the dictionary and does the lazy-load only if the desired image data is not in the cache.

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-23 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/23/2015 03:31 AM, Jeff M wrote: > sqlite3_step(); // occasionally crashes here (showing > ESC_BAD_ACCESS on main thread) That has three very likely causes. The first is that your internal state gets messed up, and the statement has actually

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-23 Thread Simon Slavin
On 23 Aug 2015, at 11:31am, Jeff M wrote: > Any ideas on how to debug this? Are you checking the values returned by sqlite3_prepare, sqlite3_bind, and sqlite3_step, to make sure they return SQLITE_OK ? I'm not quite sure what you mean by 'done once' -- whether it's once for the whole

[sqlite] ESC_BAD_ACCESS when using a background thread

2015-08-23 Thread Jeff M
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