View Issue Details

IDProjectCategoryView StatusLast Update
0037993FPCDatabasepublic2020-10-27 09:28
ReporterZamrony P. Juhara Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Fixed in Version3.3.1 
Summary0037993: TSQLConnection destructor may raise exception leading to memory leak
DescriptionFrom

https://github.com/graemeg/freepascal/blob/master/packages/fcl-db/src/sqldb/sqldb.pp

destructor TSQLConnection.Destroy;
begin
  Connected:=False; // needed because we want to de-allocate statements
  FreeAndNil(FStatements);
  inherited Destroy;
end;

If it is connected then later database server shuts down, Connected:=false may raise exception which cause destruction incomplete and leaking memory
TagsNo tags attached.
Fixed in Revision47216
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Michael Van Canneyt

2020-10-27 09:28

administrator   ~0126577

I have added a possible fix, but it is very doubtful this will catch all possible cases.

When you suspect the database connection has gone, you should set ForcedClose:=True; or use Close(True) on the connection.
This will close all datasets but ignores all errors that can happen when the DB has gone away.

Issue History

Date Modified Username Field Change
2020-10-27 03:44 Zamrony P. Juhara New Issue
2020-10-27 09:14 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-10-27 09:14 Michael Van Canneyt Status new => assigned
2020-10-27 09:22 Michael Van Canneyt Assigned To Michael Van Canneyt =>
2020-10-27 09:22 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-10-27 09:28 Michael Van Canneyt Status assigned => resolved
2020-10-27 09:28 Michael Van Canneyt Resolution open => fixed
2020-10-27 09:28 Michael Van Canneyt Fixed in Version => 3.3.1
2020-10-27 09:28 Michael Van Canneyt Fixed in Revision => 47216
2020-10-27 09:28 Michael Van Canneyt FPCTarget => 3.2.2
2020-10-27 09:28 Michael Van Canneyt Note Added: 0126577