Multiple threads and SQLite

Summary

Random access violations, when ditinct threads access to distinct sqlite databases also in exclusive way (one db accessed only by one thread)

System Information

  • Operating system: Linux, debian 11.5
  • Processor architecture: x86-64
  • Compiler version: 3.2
  • Device: Computer

Steps to reproduce

The lazarus forum post contains example program and db

Example Project

Lazarus Forum: sqlite unexpected access violations

What is the current bug behavior?

Random access violations

Possible fixes

Currently putting InitializeSQLite() before any db operation and ReleaseSQLite() after all db operations prevents the RefCounted library loading/unloading to occur everytime and solves the problem

Edited by Tomaso Tosolini