Reputation: 217
My application gets struck in an infinite loop in the finalization section in classes.pas (Delphi 2010) when calling ReleaseObjectInstanceBlocks
.
ReleaseObjectInstanceBlocks
calls GetFreeInstBlockItemCount(InstFreeList, Block)
and the problem seems to be in the InstFreeList
linked list. The function traverses that list, and it seems the list is pointing to a circular reference (and creates an infinite loop).
Any pointers on how do I find out what is causing an error at this stage? (All my forms have been freed by this time obviously)
I have located the problem to be a conflict between Owner
& Parent
. I construct a form (which I use as a "frame" by placing it on a panel) using
constructor TfrSMDControl.Create(AOwner:TComponent; AParent:TWincontrol; id:TStepperMotorDrive);
which creates a few ActiveX components in runtime.
The crash occurs given two conditions
frSMD := TfrSMDControl.Create(MainForm, Panel1, idControl);
I free the object with a FreeAndNil(frSMD)
using the following destructor
try
CWDIO.Free;
CWPulse.Free;
CWDAQTools.Free;
except on e:exception do
MyDBG.LogException(E.Message);
end;
No crash occurs if the frame is created with frSMD := TfrSMDControl.Create(nil, Panel1, idControl);
(with the same destructor exception handling code).
CWxxx
are all Ole/ActiveX components. Is there an issue with how Delphi handles ownership of and exception in OleControls ?)
Upvotes: 0
Views: 526
Reputation: 612954
The shared global structure supporting MakeObjectInstance
has been corrupted. With probability very close to 1 this is because your program breaks the VCL threading model. Somewhere in your program you are calling VCL code in a thread other than the main thread.
Upvotes: 1