Page 1 of 1

SDAC 4.50: Access Violation in ClearTransactionRefs

Posted: Thu 31 Jul 2008 10:34
by Alan009
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

Posted: Fri 08 Aug 2008 07:24
by Challenger
We could not reporduce this problem. The FTransactions object is freed after all calls to ClearTransactionRefs. Do you use the TMSTransaction component in you project? If it is possible compose a small sample and send it to sdac*devart*com.