<p class="MsoNormal">Hello,</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I feel a bit sheepish in asking for the time of members of
the community to help address my problem, but am hoping that someone will have
a quick answer to what is sure to take me a good deal of time to track down.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I am using IGSTK 4.4 with ITK 3.16 and VTK 5.2.0 on VS Team
System 2008 compiling/running in a Vista 64 machine.<span style="mso-spacerun:yes">  </span>We have modified the default CMAKE
configuration of VTK, ITK, and IGSTK to use preprocessor directives _SECURE_SCL=0
and _HAS_ITERATOR_DEBUGGING=0 for all CXX builds to remove the overhead of the
MS security checks that slow down performance.<span style="mso-spacerun:yes"> 
</span>These settings match with our existing code base’s settings (our larger
libraries of which we link to ITK,VTK,IGSTK).<span style="mso-spacerun:yes"> 
</span>I have used ITK and VTK for a few years like this with no problems.<span style="mso-spacerun:yes">  </span>All compilation is done in “Release” mode.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I had started experimenting with IGSTK and can perform
tracking with an NDI Polaris tracker with no problems.<span style="mso-spacerun:yes">  </span>An MFC GUI initiates the tracker, tracks some
tools, and closes.<span style="mso-spacerun:yes">  </span>I’ve also added the
code from IGSTKCoordinateSystemTest.cxx to this app, and everything works great,
as expected. </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Furthermore, all IGSTK tests (with the exception of <span style="font-size:8.0pt;font-family:"Courier New";mso-no-proof:yes">igstkStateMachineExportTest)</span>
pass in the IGSTK Solution when Building “RUN_TESTS”.</p>

<p class="MsoNormal"><br>
So here’s my problem.<span style="mso-spacerun:yes">   </span>As soon as I add
the following code (which is a minimum of what I’ve done to create a problem, I’ve
also tried adding igstkSpatialObjectCoordinateSystemTest3.cxx in its entirety
and get the same problem) I get problems.<span style="mso-spacerun:yes"> 
</span>Here’s the snippet in main:</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes">igstk::RealTimeClock::Initialize();</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"> </span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes">{</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-tab-count:1">      </span>{</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-tab-count:1">      </span><span style="mso-tab-count:1">      </span><span style="color:blue">typedef</span> igstk::SpatialObject<span style="mso-spacerun:yes">                    </span>CoordinateSystem;</span></p>


<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-tab-count:1">      </span><span style="mso-tab-count:1">      </span><span style="color:blue">typedef</span> CoordinateSystem::Pointer<span style="mso-spacerun:yes">               </span>CoordinateSystemPointer;</span></p>


<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-tab-count:1">      </span><span style="mso-tab-count:1">      </span>CoordinateSystemPointer
root = CoordinateSystem::New();</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"> </span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"> </span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-tab-count:1">      </span>}</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-tab-count:1">      </span><span style="color:blue">return</span> 0;</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";
mso-no-proof:yes">}</span></p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">If I run this executable outside of the debugger I get the “project.exe”
has stopped working dialog.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Inside a debugger, when root falls out of scope, I get a
heap corruption in free.c with the error popping up at retval.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes">#endif</span><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">  </span><span style="color:green">/* CRTDLL */</span></span></p>


<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">        </span><span style="color:blue">else</span><span style="mso-spacerun:yes">    </span><span style="color:green">//<span style="mso-spacerun:yes">  </span>__active_heap == __SYSTEM_HEAP</span></span></p>


<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue;mso-no-proof:yes">#endif</span><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">  </span><span style="color:green">/* _WIN64 */</span></span></p>


<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">        </span>{</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">            </span>retval = HeapFree(_crtheap, 0,
pBlock);</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">            </span><span style="color:blue">if</span>
(retval == 0)</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">            </span>{</span></p>


<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">                </span>errno =
_get_errno_from_oserr(GetLastError());</span></p>

<p class="MsoNormal" style="mso-layout-grid-align:none;text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes"><span style="mso-spacerun:yes">            </span>}</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";
mso-no-proof:yes"><span style="mso-spacerun:yes">        </span>}</span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";
mso-no-proof:yes"> </span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";
mso-no-proof:yes">Call stack looks like this:</span></p>

<p class="MsoNormal">><span style="mso-tab-count:1">              </span>msvcr90.dll!free(void
* pBlock=0x0000000000000001)<span style="mso-spacerun:yes">  </span>Line 110<span style="mso-tab-count:1"> </span>C</p>

<p class="MsoNormal"><span style="mso-spacerun:yes"> </span><span style="mso-tab-count:1">               </span>project.exe!igstk::SpatialObject::`scalar
deleting destructor'()<span style="mso-spacerun:yes">  </span>+ 0x21 bytes<span style="mso-tab-count:1">       </span>C++</p>

<p class="MsoNormal"><span style="mso-spacerun:yes"> </span><span style="mso-tab-count:1">               </span>project.exe!itk::LightObject::UnRegister()<span style="mso-spacerun:yes">  </span>+ 0x22 bytes<span style="mso-tab-count:1">               </span>C++</p>


<p class="MsoNormal"><span style="mso-spacerun:yes"> </span><span style="mso-tab-count:1">               </span>project.exe!main(int argc=0, char
* * argv=0x00000053b84b2fd1, char * * envp=0x0000000000000000)<span style="mso-spacerun:yes">  </span>Line 883<span style="mso-tab-count:1"> </span>C++</p>

<p class="MsoNormal"><span style="mso-spacerun:yes"> </span><span style="mso-tab-count:1">               </span>project.exe!__tmainCRTStartup()<span style="mso-spacerun:yes">  </span>Line 586 + 0x19 bytes<span style="mso-tab-count:
1">               </span>C</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">To test to see if it was entirely an ITK problem (and hence
whether I should post to that user group first, I tried this and did not
receive any crashes):</p>

<p class="MsoNormal">{</p>

<p class="MsoNormal" style="text-indent:.5in">{</p>

<p class="MsoNormal" style="margin-left:.5in;text-indent:.5in"><span style="font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes">itk::CylinderSpatialObject::Pointer
obj = itk::CylinderSpatialObject::New();</span></p>

<p class="MsoNormal" style="text-indent:.5in"><span style="font-size:10.0pt;
font-family:"Courier New";mso-no-proof:yes">}</span></p>

<p class="MsoNormal" style="text-indent:.5in"><span style="font-size:10.0pt;
font-family:"Courier New";mso-no-proof:yes"> </span></p>

<p class="MsoNormal" style="text-indent:.5in"><span style="font-size:10.0pt;
font-family:"Courier New";mso-no-proof:yes">return 0;</span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";
mso-no-proof:yes">}</span></p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I’m not extremely familiar with all the dependencies and MS
and/or CMake options that I may have misaligned to cause a problem.<span style="mso-spacerun:yes">  </span></p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I would be quite grateful for any guidance the community
could provide.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Sincerely,</p>

<p class="MsoNormal">Jason Gibbs</p>