Toolbar2000
Toolbar2000 copied to clipboard
Finalization crash in TB2Acc.pas in TTBCustomAccObject.Destroy on Delphi 10.4.2 64bit
In finalization unit TB2Acc.pas is destroyed critical section LastAccObjectCritSect and after that is calling TTBCustomAccObject.Destroy (releasing interfaces) where is calling EnterCriticalSection(LastAccObjectCritSect). On 32bit are all AccObject released before destroing LastAccObjectCritSect.
Isn't this a bug in Delphi x64 compiler?
The patch from this issue may help: https://github.com/SilverpointDev/sptbxlib/issues/107
TTBCustomAccObject = class(TTBBaseAccObject)
...
class var AccessibilityFinalized: Boolean;
end;
finalization
DisconnectAccObjects;
if NeedToUninitialize then
CoUninitialize;
if LastAccObject = nil then
DeleteCriticalSection(LastAccObjectCritSect)
else
TTBCustomAccObject.AccessibilityFinalized := True;
destructor TTBCustomAccObject.Destroy;
begin
{ Remove Self from linked list of objects }
EnterCriticalSection(LastAccObjectCritSect);
try
if LastAccObject = Self then
LastAccObject := FPrevious;
if Assigned(FPrevious) then
FPrevious.FNext := FNext;
if Assigned(FNext) then
FNext.FPrevious := FPrevious;
finally
LeaveCriticalSection(LastAccObjectCritSect);
end;
if AccessibilityFinalized and (LastAccObject = nil) then
DeleteCriticalSection(LastAccObjectCritSect);
inherited;
end;