Sometimes I get Access Violation in TCustomDAConnection.ClearTransactionRefs when I try to free TCustomMSConnection class.
Method TCustomDAConnection.Destroy calls TCustomDAConnection.Destroy, which at first calls Disconnect, which causes the first call of TCustomDAConnection.ClearTransactionRefs. The first call works fine and calls successfully FTransactions.FreeITransaction for the single item of FTransactions list.
After that TCustomDAConnection.Destroy calls FreeITransactions, which causes the second call of TCustomDAConnection.ClearTransactionRefs. Now strange things begin to happen. It seems to me, that FTransactions list is already destroyed, but the value of FTransactions is not set to NIL, so the call to FTransactions.Count in ClearTransactionRefs can return any random value (if not causes access violation). So, when FTransactions.Count returns non zero value, ClearTransactionRefs tries to call FTransactions.FreeITransaction again, but Access Violation exception is raised, when trying to get the first element of FTransactions list (FTransactions.FITransaction).
The error can be reproduced, if the time period between the two calls to ClearTransactionRefs is small. When the program waits on a breakpoint after the first call for a long time (for a 30 sec for example), the second call to ClearTransactionRefs is usually successful.
PS
SDAC 4.50
Windows XP SP2
MS SQL Server 2005
Delphi 7
SDAC 4.50: Access Violation in ClearTransactionRefs
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53