System.Data.SQLite
View Ticket
Not logged in
Ticket UUID: f10b131f8fd0f49c97390297be77ce92ae7919a1
Title: Attempted to read or write protected memory
Status: Closed Type: Incident
Severity: Important Priority: Medium
Subsystem: Integration_Via_PInvoke Resolution: Works_As_Designed
Last Modified: 2019-02-11 11:46:05
Version Found In: 1.0.109.0
User Comments:
anonymous added on 2019-02-06 16:01:39: (text/x-fossil-plain)
I'm trying to enable multi-thread mode so I've built the project SQLite.Interop.2017 after setting SQLITE_THREADSAFE=2 in sqlite3.props and sqlite3.vsprops. 

Os: Windows 10.
IDE : VS 2017

Using the compiled System.Data.SQLite.dll and SQLite.Interop.dll in my code
causes an exception even though I'm not accessing the db from multiple threads.

Exception: System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'


Please note that if I build the project with SQLITE_THREADSAFE=1 then everything works just fine.

mistachkin added on 2019-02-08 02:19:01: (text/x-fossil-plain)
Changing the default threading mode for the SQLite core library is not recommended
when using System.Data.SQLite.  For example, there can be some difficulties when
using things like the connection pool.

Is it possible that one than one thread is trying to make use of a connection
-OR- another object type associated with a connection (e.g. SQLiteCommand,
SQLiteDataReader, SQLiteTransaction, etc)?

anonymous added on 2019-02-10 07:34:20: (text/x-fossil-plain)
You are correct it seems if you properly dispose the Command(s) and DataReader(s) the problem wont appear.