Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

NullReferenceException from sqlite3_prepare

2006-04-05
2013-04-15
  • I am using sqlite via the Finisar API in a heavy load environment to implment a queue.  We have encountered a sporadic problem that we haven't yet been able to isolate.  Here's what the call stack looks like:

    System.NullReferenceException: Object reference not set to an instance of an object.
       at Finisar.SQLite.sqlite3.sqlite3_prepare(IntPtr db, IntPtr zSql, Int32 nBytes, IntPtr& ppVm, IntPtr& pzTail)
       at Finisar.SQLite.sqlite3.compile(String zSql) in D:\projects\trunk\third-party\SQLite.NET\CSharpSources\SQLite.NET\sqlite3.cs:line 651
       at Finisar.SQLite.OneSQLStatement.Compile() in D:\projects\trunk\third-party\SQLite.NET\CSharpSources\SQLite.NET\OneSQLStatement.cs:line 83
       at Finisar.SQLite.SQLiteDataReader.ExecuteFirstStep() in D:\projects\trunk\third-party\SQLite.NET\CSharpSources\SQLite.NET\DataReader.cs:line 83
       at Finisar.SQLite.SQLiteDataReader.EnsureInitialization() in D:\projects\trunk\third-party\SQLite.NET\CSharpSources\SQLite.NET\DataReader.cs:line 72
       at Finisar.SQLite.SQLiteDataReader.Read() in D:\projects\trunk\third-party\SQLite.NET\CSharpSources\SQLite.NET\DataReader.cs:line 291
       at Tanagra.DataClad.MessageQueue.SQLiteMessageQueue.DoDequeue(SQLiteConnection conn) in D:\projects\trunk\DataClad\MessageQueue\SQLiteMessageQueue.cs:line 221
       at Tanagra.DataClad.MessageQueue.SQLiteMessageQueue.Dequeue() in D:\projects\trunk\DataClad\MessageQueue\SQLiteMessageQueue.cs:line 106
       at Tanagra.DataClad.BackupMessageSink.DoProcessQueue(IMessageQueue queue)

    This problem is intermittent (only happens every few hours, or sometimes not at all).  We have also seen that when the problem starts happening, it continues for a few minutes then magically abates.  Another interesting tidbit is that many handles to the sqlite3 db file are leaked when things go south.

    I'm using 0.21 of the SQLite.NET lib and 3.3.4 sqlite3.dll