[Insight-users] BCB5 and itk - please help

John Biddiscombe john.biddiscombe@mirada-solutions.com
Wed, 19 Feb 2003 11:30:21 -0000


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.0.6249.1">
<TITLE>[Insight-users] BCB5 and itk - please help</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT FACE=3D"Times New Roman">Dean<BR>
<BR>
Does it still crash if you do this...<BR>
filter =3D FilterType::New();<BR>
filter-&gt;Unregister();<BR>
filter =3D NULL;<BR>
<BR>
ie explicitly delete the filter and set the pointer to null before =
exit.<BR>
<BR>
JB<BR>
<BR>
----- Original Message -----<BR>
From: &lt;<U></U></FONT><U><FONT COLOR=3D"#0000FF" FACE=3D"Times New =
Roman">dean.inglis@on.aibn.com &lt;<A =
HREF=3D"mailto:dean.inglis@on.aibn.com">mailto:dean.inglis@on.aibn.com</A=
>&gt;</FONT></U><FONT FACE=3D"Times New Roman">&gt;<BR>
To: &lt;</FONT><U><FONT COLOR=3D"#0000FF" FACE=3D"Times New =
Roman">insight-users@public.kitware.com &lt;<A =
HREF=3D"mailto:insight-users@public.kitware.com">mailto:insight-users@pub=
lic.kitware.com</A>&gt;</FONT></U><FONT FACE=3D"Times New =
Roman">&gt;<BR>
Sent: Tuesday, February 18, 2003 3:08 PM<BR>
Subject: [Insight-users] BCB5 and itk - please help<BR>
<BR>
<BR>
&gt; Ok, last ditch appeal for help. Here is the call stack for<BR>
&gt; simple Borland C++ Builder GUI app that instantiates an itk<BR>
&gt; object (BinomialBlurImageFilter) in the form's constructor.<BR>
&gt; On exiting the app, it appears that the itk object proceeds<BR>
&gt; through its destruction sequence, but after the form that<BR>
&gt; owns it is destroyed, thereby resulting in memory access<BR>
&gt; violation:<BR>
&gt;<BR>
&gt;<BR>
&gt; 77F85C41 ntdll.dll<BR>
&gt; 77F85BD1 ntdll.dll<BR>
&gt; 004279FD itk::TimeStamp::Modified<BR>
&gt; 004215A9 itk::Object::Modified<BR>
&gt; 0041CF8D itk::DataObject::Initialize<BR>
&gt; 00425097 itk::ProcessObject::~ProcessObject<BR>
&gt; 004055E7 itk::ImageSource&lt;itk::Image&lt;float, 2&gt;<BR>
&gt;::~ImageSource&lt;itk::Image&lt;float, 2&gt; =
&gt;(this=3D:01044E54)<BR>
&gt; 00408E33 itk::ImageToImageFilter&lt;itk::Image&lt;float, 2&gt;, =
itk::Image&lt;float,<BR>
2&gt; &gt;::~ImageToImageFilter&lt;itk::Image&lt;float, 2&gt;, =
itk::Image&lt;float, 2&gt;<BR>
&gt;(this=3D:01044E54)<BR>
&gt; 004054CB itk::BinomialBlurImageFilter&lt;itk::Image&lt;float, =
2&gt;,<BR>
itk::Image&lt;float, 2&gt; =
&gt;::~BinomialBlurImageFilter&lt;itk::Image&lt;float, 2&gt;,<BR>
itk::Image&lt;float, 2&gt; &gt;(this=3D:01044E54)<BR>
&gt; 0041F4AE itk::LightObject::UnRegister<BR>
&gt; 00421B85 itk::Object::UnRegister<BR>
&gt; 004036D5 =
itk::SmartPointer&lt;itk::BinomialBlurImageFilter&lt;itk::Image&lt;float,=
<BR>
2&gt;, itk::Image&lt;float, 2&gt; &gt; =
&gt;::UnRegister(this=3D:01042FC0)<BR>
&gt; 00403644 =
itk::SmartPointer&lt;itk::BinomialBlurImageFilter&lt;itk::Image&lt;float,=
<BR>
2&gt;, itk::Image&lt;float, 2&gt; &gt;<BR>
&gt;::~SmartPointer&lt;itk::BinomialBlurImageFilter&lt;itk::Image&lt;floa=
t, 2&gt;,<BR>
itk::Image&lt;float, 2&gt; &gt; &gt;(this=3D:01042FC0)<BR>
&gt; 0040386E TForm1::~TForm1(this=3D:01042CEC)<BR>
&gt; 0045BD31 Classes::TComponent::DestroyComponents<BR>
&gt; 0047EB3B __init_exit_proc<BR>
&gt; 0047EB8A __cleanup<BR>
&gt; 0047DE4C _exit<BR>
&gt; 0047ED60 __startup<BR>
&gt;<BR>
&gt; Here is what happens if the filter is initialized with =
-&gt;DebugOn() :<BR>
&gt;<BR>
&gt; 77F85C41 ntdll.dll<BR>
&gt; 77F85BD1 ntdll.dll<BR>
&gt; 004279F5 itk::TimeStamp::Modified<BR>
&gt; 004215A1 itk::Object::Modified<BR>
&gt; 00421FA5 itk::Object::Object<BR>
&gt; 004243BE itk::OutputWindow::OutputWindow<BR>
&gt; 00424882 itk::Win32OutputWindow::New<BR>
&gt; 00424778 itk::OutputWindow::GetInstance<BR>
&gt; 004245A0 itk::OutputWindowDisplayDebugText<BR>
&gt; 00421A28 itk::Object::UnRegister<BR>
&gt; 004036CD =
itk::SmartPointer&lt;itk::BinomialBlurImageFilter&lt;itk::Image&lt;float,=
<BR>
2&gt;, itk::Image&lt;float, 2&gt; &gt; =
&gt;::UnRegister(this=3D:01042FC0)<BR>
&gt; 0040363C =
itk::SmartPointer&lt;itk::BinomialBlurImageFilter&lt;itk::Image&lt;float,=
<BR>
2&gt;, itk::Image&lt;float, 2&gt; &gt;<BR>
&gt;::~SmartPointer&lt;itk::BinomialBlurImageFilter&lt;itk::Image&lt;floa=
t, 2&gt;,<BR>
itk::Image&lt;float, 2&gt; &gt; &gt;(this=3D:01042FC0)<BR>
&gt; 00403866 TForm1::~TForm1(this=3D:01042CEC)<BR>
&gt; 0045BD29 Classes::TComponent::DestroyComponents<BR>
&gt; 0047EB33 __init_exit_proc<BR>
&gt; 0047EB82 __cleanup<BR>
&gt; 0047DE44 _exit<BR>
&gt; 0047ED58 __startup<BR>
&gt;<BR>
&gt;<BR>
&gt; I have enclosed the relevant files for anyone who would like to<BR>
&gt; verify this behaviour. ITK is build with CMake 1.6.4, =
MinSizeRel,<BR>
&gt; Borland compiler on Win 2k, single Pentium 4 processor. I have<BR>
&gt; also posted to the Borland newsgroups but without much success.<BR>
&gt; Any help would be great,<BR>
&gt;<BR>
&gt;<BR>
&gt; Dean<BR>
&gt;<BR>
&gt;<BR>
&gt; Here is the form's class definition (itkObjectTest.h):<BR>
&gt;<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt;<BR>
&gt; #ifndef itkObjectTestH<BR>
&gt; #define itkObjectTestH<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt; #include &lt;Classes.hpp&gt;<BR>
&gt; #include &lt;Controls.hpp&gt;<BR>
&gt; #include &lt;StdCtrls.hpp&gt;<BR>
&gt; #include &lt;Forms.hpp&gt;<BR>
&gt;<BR>
&gt; #include &quot;itkImage.h&quot;<BR>
&gt; #include &quot;itkBinomialBlurImageFilter.h&quot;<BR>
&gt;<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt; class TForm1 : public TForm<BR>
&gt; {<BR>
&gt; __published: // IDE-managed Components<BR>
&gt; TLabel *Label1;<BR>
&gt; private: // User declarations<BR>
&gt; public: // User declarations<BR>
&gt; __fastcall TForm1(TComponent* Owner);<BR>
&gt; __fastcall ~TForm1();<BR>
&gt;<BR>
&gt; typedef itk::Image&lt;float, 2&gt; ImageType;<BR>
&gt; typedef itk::BinomialBlurImageFilter&lt; ImageType, ImageType =
&gt;<BR>
FilterType;<BR>
&gt; FilterType::Pointer filter;<BR>
&gt;<BR>
&gt; };<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt; extern PACKAGE TForm1 *Form1;<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt; #endif<BR>
&gt;<BR>
&gt;<BR>
&gt; Here is the implementation (itkObjectTest.cpp):<BR>
&gt;<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt;<BR>
&gt; #include &lt;vcl.h&gt;<BR>
&gt; #pragma hdrstop<BR>
&gt;<BR>
&gt; #include &quot;itkObjectTest.h&quot;<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt; #pragma package(smart_init)<BR>
&gt; #pragma resource &quot;*.dfm&quot;<BR>
&gt; TForm1 *Form1;<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt; __fastcall TForm1::TForm1(TComponent* Owner)<BR>
&gt; : TForm(Owner)<BR>
&gt; {<BR>
&gt; filter =3D FilterType::New();<BR>
&gt; }<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt; __fastcall TForm1::~TForm1()<BR>
&gt; {<BR>
&gt; return;<BR>
&gt; }<BR>
&gt;<BR>
&gt;<BR>
&gt; Here is the form's GUI element description (itkObjectTest.dfm):<BR>
&gt;<BR>
&gt; object Form1: TForm1<BR>
&gt; Left =3D 197<BR>
&gt; Top =3D 304<BR>
&gt; Width =3D 279<BR>
&gt; Height =3D 181<BR>
&gt; Caption =3D 'Form1'<BR>
&gt; Color =3D clBtnFace<BR>
&gt; Font.Charset =3D DEFAULT_CHARSET<BR>
&gt; Font.Color =3D clWindowText<BR>
&gt; Font.Height =3D -11<BR>
&gt; Font.Name =3D 'MS Sans Serif'<BR>
&gt; Font.Style =3D []<BR>
&gt; OldCreateOrder =3D False<BR>
&gt; PixelsPerInch =3D 96<BR>
&gt; TextHeight =3D 13<BR>
&gt; object Label1: TLabel<BR>
&gt; Left =3D 80<BR>
&gt; Top =3D 48<BR>
&gt; Width =3D 100<BR>
&gt; Height =3D 32<BR>
&gt; Caption =3D 'ITK Test'<BR>
&gt; Font.Charset =3D DEFAULT_CHARSET<BR>
&gt; Font.Color =3D clWindowText<BR>
&gt; Font.Height =3D -27<BR>
&gt; Font.Name =3D 'MS Sans Serif'<BR>
&gt; Font.Style =3D []<BR>
&gt; ParentFont =3D False<BR>
&gt; end<BR>
&gt; end<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt; Here is the application implementation (itkObjTestPrj.cpp):<BR>
&gt;<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt;<BR>
&gt; #include &lt;vcl.h&gt;<BR>
&gt; #pragma hdrstop<BR>
&gt; USERES(&quot;itkObjTestPrj.res&quot;);<BR>
&gt; USEFORM(&quot;itkObjectTest.cpp&quot;, Form1);<BR>
&gt; USELIB(&quot;..\..\Backup\VXLNumerics.lib&quot;);<BR>
&gt; USELIB(&quot;..\..\Backup\ITKBasicFilters.lib&quot;);<BR>
&gt; USELIB(&quot;..\..\Backup\ITKCommon.lib&quot;);<BR>
&gt; USELIB(&quot;..\..\Backup\ITKAlgorithms.lib&quot;);<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt; WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)<BR>
&gt; {<BR>
&gt; try<BR>
&gt; {<BR>
&gt; Application-&gt;Initialize();<BR>
&gt; Application-&gt;CreateForm(__classid(TForm1), &amp;Form1);<BR>
&gt; Application-&gt;Run();<BR>
&gt; }<BR>
&gt; catch (Exception &amp;exception)<BR>
&gt; {<BR>
&gt; Application-&gt;ShowException(&amp;exception);<BR>
&gt; }<BR>
&gt; return 0;<BR>
&gt; }<BR>
&gt;<BR>
//-----------------------------------------------------------------------=
---<BR>
-<BR>
&gt;<BR>
&gt; _______________________________________________<BR>
&gt; Insight-users mailing list<BR>
&gt;</FONT><U> <FONT COLOR=3D"#0000FF" FACE=3D"Times New =
Roman">Insight-users@public.kitware.com &lt;<A =
HREF=3D"mailto:Insight-users@public.kitware.com">mailto:Insight-users@pub=
lic.kitware.com</A>&gt;</FONT></U><BR>
<FONT FACE=3D"Times New Roman">&gt;</FONT><U> <FONT COLOR=3D"#0000FF" =
FACE=3D"Times New Roman">&lt;<A =
HREF=3D"http://public.kitware.com/mailman/listinfo/insight-users">http://=
public.kitware.com/mailman/listinfo/insight-users</A>&gt;</FONT></U><BR>

</P>

</BODY>
</HTML>