SQLite User Forum

Unhandled NRE in SQLite
Login

Unhandled NRE in SQLite

(1.1) Originally by j@Verisk (jverisk) with edits by Dan Kennedy (dan) on 2022-08-19 16:36:11 from 1.0 [source]

We're having some issues with our unit tests failing. We've tracked it down to a Null Reference Exception being thrown from SQLite. On any given run we will have several tests fail with this error, but there isn't any consistency in regards to which tests will fail. We've tried forcing the tests to run with no parallelization to no avail. We are running the latest version released in the nuget package for .NET (v.1.0.116.) Exception details below.

Exception:
Object reference not set to an instance of an object

Data:
System.Collections.ListDictionaryInternal

StackTrace:
at System.Data.SQLite.UnsafeNativeMethods.sqlite3_step(IntPtr stmt)\r\n
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)\r\n
at System.Data.SQLite.SQLiteDataReader.NextResult()\r\n
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)\r\n
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)\r\n
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)\r\n

(2) By mistachkin on 2022-08-19 18:56:04 in reply to 1.1 [link] [source]

Is the same connection being used by multiple threads?

Do you have a short example in C# that demonstrates the issue?

(3) By j@Verisk (jverisk) on 2022-08-22 22:37:27 in reply to 2 [link] [source]

No, as briefly explained below a database in our unit tests lives for the duration of a test and will only ever have a single connection.

I will try to put together a sample solution that reproduces the issue.

Each test creates a new, uniquely named DB on disk, runs whatever query(ies) it needs to then deletes the DB. We are using SEE to encrypt our databases, and I discovered that removing the encryption and code needed to initialize SEE fixed the failures.

As I said, I'll try to replicate it in a sample program, but maybe that info helps narrow down the possible cause?

(4) By mistachkin on 2022-08-26 16:24:14 in reply to 3 [link] [source]

Could you please post the follow-ups to the SEE forum?

  https://www.sqlite.org/see/forum