Page 1 of 1

TZConnection.Free causes List index out of bounds error

Posted: 11.02.2021, 11:20
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.

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

Posted: 11.02.2021, 11:48
by marsupilami
The patch is applied to trunk. I will leave it to Egonhugeist to merge it back into 8.0.

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

Posted: 11.02.2021, 12:58
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.