The application has threads and multiple threads might make a connection the SQLite db. Every connection is closed after the command executed on sqlite db. However there is a chance of race condition in acquiring new connection before a previous connection is closed. Randomly access violations happen. Below is the stack trace. Does this race condition of acquiring connection, create access violation?
03-12-23 10:37:25.651
Exception EAccessViolation: Access violation at address 0175733E in module 'MyApp.exe'. Read of address 00000034 (OS Exception)
Exception occured at $0175733E (Module "FireDAC.Phys.SQLiteCli", Procedure "FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2", Unit "", Line 0)
Except frame-dump:
Frame at $1B16F9BC (type: efkFinally)
Code at $00CDEB72
Module "FireDAC.Comp.Client", Procedure "FireDAC.Comp.Client.TFDCustomCommand.SetPrepared", Unit "", Line 0 Frame at $1B16F9C8 (type: efkFinally)
Code at $00CDEDAC
Module "FireDAC.Comp.Client", Procedure "FireDAC.Comp.Client.TFDCustomCommand.SetPrepared", Unit "", Line 0 Frame at $1B16F9D4 (type: efkFinally)
Code at $00CDEDC8
Module "FireDAC.Comp.Client", Procedure "FireDAC.Comp.Client.TFDCustomCommand.SetPrepared", Unit "", Line 0 Frame at $1B16FA58 (type: efkFinally)
Code at $00CE5A3C
Module "FireDAC.Comp.Client", Procedure "FireDAC.Comp.Client.TFDAdaptedDataSet.DoPrepareSource", Unit "", Line 0 Frame at $1B16FA8C (type: efkFinally)
Code at $00CAB85B
Module "FireDAC.Comp.DataSet", Procedure "FireDAC.Comp.DataSet.TFDDataSet.OpenCursor", Unit "", Line 0 Frame at $1B16FA98 (type: efkFinally)
Code at $00CAB878
Module "FireDAC.Comp.DataSet", Procedure "FireDAC.Comp.DataSet.TFDDataSet.OpenCursor", Unit "", Line 0 Frame at $1B16FAC0 (type: efkAnyException, handles exception)
Handler at $00CE7FBA
Module "FireDAC.Comp.Client", Procedure "FireDAC.Comp.Client.TFDRdbmsDataSet.OpenCursor", Unit "", Line 0
03-12-23 10:37:25.885
---Start Stack Trace---
(0135633E){MyApp.exe } [0175733E] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $49E6
(0130CD6F){MyApp.exe } [0170DD6F] FireDAC.Phys.SQLiteCli.sqlite3_vfs_unregister + $3F3
(0130CBCB){MyApp.exe } [0170DBCB] FireDAC.Phys.SQLiteCli.sqlite3_vfs_unregister + $24F
(0130EF4E){MyApp.exe } [0170FF4E] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $10E
(01311F5C){MyApp.exe } [01712F5C] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $311C
(0131645D){MyApp.exe } [0171745D] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $761D
(013164E2){MyApp.exe } [017174E2] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $76A2
(0131682B){MyApp.exe } [0171782B] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $79EB
(01318D83){MyApp.exe } [01719D83] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $9F43
(01319109){MyApp.exe } [0171A109] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $A2C9
(0131E076){MyApp.exe } [0171F076] FireDAC.Phys.SQLiteCli.sqlite3_enable_shared_cache + $17C6
(0131EDEB){MyApp.exe } [0171FDEB] FireDAC.Phys.SQLiteCli.sqlite3_enable_shared_cache + $253B
(0131F98B){MyApp.exe } [0172098B] FireDAC.Phys.SQLiteCli.sqlite3_enable_shared_cache + $30DB
(0131F9F5){MyApp.exe } [017209F5] FireDAC.Phys.SQLiteCli.sqlite3_enable_shared_cache + $3145
(0135C229){MyApp.exe } [0175D229] FireDAC.Phys.SQLiteCli.sqlite3_declare_vtab + $351
(0130CD6F){MyApp.exe } [0170DD6F] FireDAC.Phys.SQLiteCli.sqlite3_vfs_unregister + $3F3
(0130CBCB){MyApp.exe } [0170DBCB] FireDAC.Phys.SQLiteCli.sqlite3_vfs_unregister + $24F
(0131C766){MyApp.exe } [0171D766] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $D926
(0131C812){MyApp.exe } [0171D812] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $D9D2
(01328FC2){MyApp.exe } [01729FC2] FireDAC.Phys.SQLiteCli.sqlite3_backup_pagecount + $2CA2
(01328FE5){MyApp.exe } [01729FE5] FireDAC.Phys.SQLiteCli.sqlite3_backup_pagecount + $2CC5
(01333DD9){MyApp.exe } [01734DD9] FireDAC.Phys.SQLiteCli.sqlite3_value_numeric_type + $665D
(0130EB7F){MyApp.exe } [0170FB7F] FireDAC.Phys.SQLiteCli.sqlite3_free + $17D7
(0130E8CD){MyApp.exe } [0170F8CD] FireDAC.Phys.SQLiteCli.sqlite3_free + $1525
(0133B103){MyApp.exe } [0173C103] FireDAC.Phys.SQLiteCli.sqlite3_blob_bytes + $6A93
(0133B1A0){MyApp.exe } [0173C1A0] FireDAC.Phys.SQLiteCli.sqlite3_blob_bytes + $6B30
(0133B434){MyApp.exe } [0173C434] FireDAC.Phys.SQLiteCli.sqlite3_blob_bytes + $6DC4
(0132888B){MyApp.exe } [0172988B] FireDAC.Phys.SQLiteCli.sqlite3_backup_pagecount + $256B
(01328165){MyApp.exe } [01729165] FireDAC.Phys.SQLiteCli.sqlite3_backup_pagecount + $1E45
(013280A3){MyApp.exe } [017290A3] FireDAC.Phys.SQLiteCli.sqlite3_backup_pagecount + $1D83
(0133BFD2){MyApp.exe } [0173CFD2] FireDAC.Phys.SQLiteCli.sqlite3_blob_bytes + $7962
(0130EB7F){MyApp.exe } [0170FB7F] FireDAC.Phys.SQLiteCli.sqlite3_free + $17D7
(0130E8CD){MyApp.exe } [0170F8CD] FireDAC.Phys.SQLiteCli.sqlite3_free + $1525
(0130EB7F){MyApp.exe } [0170FB7F] FireDAC.Phys.SQLiteCli.sqlite3_free + $17D7
(0130E8CD){MyApp.exe } [0170F8CD] FireDAC.Phys.SQLiteCli.sqlite3_free + $1525
(01338A47){MyApp.exe } [01739A47] FireDAC.Phys.SQLiteCli.sqlite3_blob_bytes + $43D7
(0130EBF5){MyApp.exe } [0170FBF5] FireDAC.Phys.SQLiteCli.sqlite3_free + $184D
(0130EC9F){MyApp.exe } [0170FC9F] FireDAC.Phys.SQLiteCli.sqlite3_free + $18F7
(01341371){MyApp.exe } [01742371] FireDAC.Phys.SQLiteCli.sqlite3_set_authorizer + $77D
(01355F81){MyApp.exe } [01756F81] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $4629
(0130ECC7){MyApp.exe } [0170FCC7] FireDAC.Phys.SQLiteCli.sqlite3_free + $191F
(01356330){MyApp.exe } [01757330] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $49D8
(013278F1){MyApp.exe } [017288F1] FireDAC.Phys.SQLiteCli.sqlite3_backup_pagecount + $15D1
(01359B2B){MyApp.exe } [0175AB2B] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $81D3
(01336EF5){MyApp.exe } [01737EF5] FireDAC.Phys.SQLiteCli.sqlite3_blob_bytes + $2885
(013569BB){MyApp.exe } [017579BB] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $5063
(01356A88){MyApp.exe } [01757A88] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $5130
(01356F2A){MyApp.exe } [01757F2A] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $55D2
(00006488){MyApp.exe } [00407488] System.@FreeMem + $4
(001521DA){MyApp.exe } [005531DA] System.Win.Crtl.free + $6
(0130CA2E){MyApp.exe } [0170DA2E] FireDAC.Phys.SQLiteCli.sqlite3_vfs_unregister + $B2
(0130D456){MyApp.exe } [0170E456] FireDAC.Phys.SQLiteCli.sqlite3_free + $AE
(0130EBF5){MyApp.exe } [0170FBF5] FireDAC.Phys.SQLiteCli.sqlite3_free + $184D
(0130EC9F){MyApp.exe } [0170FC9F] FireDAC.Phys.SQLiteCli.sqlite3_free + $18F7
(0130D66B){MyApp.exe } [0170E66B] FireDAC.Phys.SQLiteCli.sqlite3_free + $2C3
(01351A6A){MyApp.exe } [01752A6A] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $112
(01338F92){MyApp.exe } [01739F92] FireDAC.Phys.SQLiteCli.sqlite3_blob_bytes + $4922
(0136680A){MyApp.exe } [0176780A] FireDAC.Phys.SQLiteCli.sqlite3_vtab_config + $A132
(01366697){MyApp.exe } [01767697] FireDAC.Phys.SQLiteCli.sqlite3_vtab_config + $9FBF
(0131C766){MyApp.exe } [0171D766] FireDAC.Phys.SQLiteCli.sqlite3_randomness + $D926
(0130CD55){MyApp.exe } [0170DD55] FireDAC.Phys.SQLiteCli.sqlite3_vfs_unregister + $3D9
(0130CD6F){MyApp.exe } [0170DD6F] FireDAC.Phys.SQLiteCli.sqlite3_vfs_unregister + $3F3
(0130CBCB){MyApp.exe } [0170DBCB] FireDAC.Phys.SQLiteCli.sqlite3_vfs_unregister + $24F
(0000EEF8){MyApp.exe } [0040FEF8] System.@IntfClear + $10
(008D6D8E){MyApp.exe } [00CD7D8E] FireDAC.Comp.Client.TFDCustomConnection.GetParentOptions + $5A
(008907C9){MyApp.exe } [00C917C9] FireDAC.Stan.Option.TFDFetchOptions.GetMode + $1D
(013681BF){MyApp.exe } [017691BF] FireDAC.Phys.SQLiteCli.sqlite3_vtab_config + $BAE7
(01368100){MyApp.exe } [01769100] FireDAC.Phys.SQLiteCli.sqlite3_vtab_config + $BA28
(01368A2D){MyApp.exe } [01769A2D] FireDAC.Phys.SQLiteCli.sqlite3_vtab_config + $C355
(01351503){MyApp.exe } [01752503] FireDAC.Phys.SQLiteCli.sqlite3_reset_auto_extension + $386B
(013264DE){MyApp.exe } [017274DE] FireDAC.Phys.SQLiteCli.sqlite3_backup_pagecount + $1BE
(01351715){MyApp.exe } [01752715] FireDAC.Phys.SQLiteCli.sqlite3_reset_auto_extension + $3A7D
(013518C6){MyApp.exe } [017528C6] FireDAC.Phys.SQLiteCli.sqlite3_prepare_v2 + $BE
(01351971){MyApp.exe } [01752971] FireDAC.Phys.SQLiteCli.sqlite3_prepare16_v2 + $19
(013AE6B4){MyApp.exe } [017AF6B4] FireDAC.Phys.SQLiteWrapper.TSQLiteStatement.PrepareBase + $74
(013AE951){MyApp.exe } [017AF951] FireDAC.Phys.SQLiteWrapper.TSQLiteStatement.Prepare + $2D
(013AE8FD){MyApp.exe } [017AF8FD] FireDAC.Phys.SQLiteWrapper.TSQLiteStatement.Prepare + $39
(013B914C){MyApp.exe } [017BA14C] FireDAC.Phys.SQLite.TFDPhysSQLiteCommand.InternalPrepare + $EC
(012F5314){MyApp.exe } [016F6314] FireDAC.Phys.TFDPhysTransaction.Notify + $58
(012FB0E6){MyApp.exe } [016FC0E6] FireDAC.Phys.TFDPhysCommand.Prepare + $1FE
(008DD732){MyApp.exe } [00CDE732] FireDAC.Comp.Client.TFDCustomCommand.InternalPrepare + $1DE
(008DDA8E){MyApp.exe } [00CDEA8E] FireDAC.Comp.Client.TFDCustomCommand.SetPrepared + $1BE
(0003F30C){MyApp.exe } [0044030C] System.Variants.VarClearDeep + $6C
(008DDFC9){MyApp.exe } [00CDEFC9] FireDAC.Comp.Client.TFDCustomCommand.Prepare + $19
(008E4A1A){MyApp.exe } [00CE5A1A] FireDAC.Comp.Client.TFDAdaptedDataSet.DoPrepareSource + $D6
(008AA974){MyApp.exe } [00CAB974] FireDAC.Comp.DataSet.TFDDataSet.IsLinked + $10
(008AA6EE){MyApp.exe } [00CAB6EE] FireDAC.Comp.DataSet.TFDDataSet.OpenCursor + $1EA
(008E6FA6){MyApp.exe } [00CE7FA6] FireDAC.Comp.Client.TFDRdbmsDataSet.OpenCursor + $4A
(002C68E5){MyApp.exe } [006C78E5] Data.DB.TDataSet.SetActive + $55
(008A7837){MyApp.exe } [00CA8837] FireDAC.Comp.DataSet.TFDDataSet.SetActive + $2B
(002C6721){MyApp.exe } [006C7721] Data.DB.TDataSet.Open + $9
(011AC649){MyApp.exe } [015AD649] uMyCache.TMyCacheReadItems.Execute + $A9
uMyCache.TMyCacheExecutionThread.Execute + $9F
(000DBCFD){MyApp.exe } [004DCCFD] System.Classes.ThreadProc + $49
(0000A200){MyApp.exe } [0040B200] System.ThreadWrapper + $28
---End Stack Trace---