Recent

Author Topic: free pascal sqlite and mutithreading  (Read 645 times)

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
free pascal sqlite and mutithreading
« on: February 29, 2024, 01:48:01 pm »
As emerges from

https://forum.lazarus.freepascal.org/index.php/topic,66432.0.html

if the following situation occurs:

  • there are multiple threads
  • each thread accesses one or more sqlite databases
  • each sqlite database is accessed only by one thread
  • every time one database is accessed, all the connection/transation/query objects are created and destroyed


It is possible to experience access violations, apparently due to the malfunction of the multithreaded refcouting system implemented in the fp software to wrap the libsqlite3.so (tested in linux, I have done no test for windows).

At the moment the workaround is to call

Code: Pascal  [Select][+][-]
  1. InitializeSQLite();
  2.  

before any sqlite db operation is made (example at program startup), then and call

Code: Pascal  [Select][+][-]
  1. ReleaseSQLite();
  2.  

after all sqlite db operation were made (example at program end).


« Last Edit: February 29, 2024, 01:49:53 pm by Чебурашка »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

 

TinyPortal © 2005-2018