TZConnection.Free causes List index out of bounds error

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 794
Joined: 18.11.2018, 17:37
Location: Hungary

TZConnection.Free causes List index out of bounds error

Post by aehimself »

When the TZAbstractConnection.UnregisterAllComponents cycle is going through all queries and sets the Connection property to nil, TZAbstractRODataset.SetConnection is calling FConnection.UnregisterComponent(Self) - therefore removing the item from the FLinkedComponents list UnregisterAllComponents is currently enumerating.

E.g. in the first cycle it has 2 elements, calling unregister on one makes the list to have only 1 element (with the index of 0). The second cycle is attempting to remove index 1 - raising the error.

Fix is available on GitHub.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: TZConnection.Free causes List index out of bounds error

Post by marsupilami »

The patch is applied to trunk. I will leave it to Egonhugeist to merge it back into 8.0.
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 794
Joined: 18.11.2018, 17:37
Location: Hungary

Re: TZConnection.Free causes List index out of bounds error

Post by aehimself »

This was quick! Thank you :)

Edit: I don't know in what condition this error shows up, this is the first time it happened. My application has ~5-10 types of worker threads and only one generated this. Therefore I don't really know how to reproduce.
The error is explained in my first post, so this can make sense.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
Post Reply