I am trying to use SQLite 3.7.5 in a multithreaded C ++ program. I narrowed it down to a few simple lines of code:
sqlite3 *Database; sqlite3_stmt *Stmt; int retval=sqlite3_open("database.db3",&Database); retVal=sqlite3_prepare(&Database,"CREATE TABLE RawData (Key CHAR(5))",-1,&Stmt,0); retval=sqlite3_step(Stmt); retval=sqlite3_finalize(Stmt);
When I call this code directly from my main process, it works fine. However, if I use CreateThread () to create a thread:
unsigned long ThreadId; CreateThread(0,0,(LPTHREAD_START_ROUTINE) InserterThread,&Info,0,&ThreadId);
I get a Visual Buffer Forwarding message in sqlite3_step call. If I debug, I see that the location of the failure is in _CRT_DEBUGGER_HOOK in the dbghook.c file.
I use the multi-threaded Static VC libraries and compile with define:
SQLITE_THREADSAFE=2 THREADSAFE=2
I checked with sqlite3_threadsafe () .
I can track the SQLite 3 code a bit, but I hope someone finds an obvious problem with my code and saves me.
source share