<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">Hi All,</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">I attached a simple test code basically reading in an image, and I just realized that it will crash at ImageReader->Update() [actually at ITKProcessObject::GenerateOutputInformation() ] when I compile at release mode but was fine at Debug mode. </font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">I searched in the mailing list, and (thought) I have ruled out the cause of uninitialized variable or destructed smartpointer, so I came up with this test code and the problem is
still there! </font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">I would appreciate if anyone can help to find what's the problem? Thanks a lot!</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span"><div style="font-size: 12pt; font-family: times, serif; ">IDE: windows7 Visual Studio 2008</div><div style="font-size: 12pt; font-family: times, serif; ">ITK/Application: 3.20.0 </div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; ">Here are the link of the code and the CMakeList, I also paste the code at the end.</div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div><font class="Apple-style-span" face="times, serif">http://dl.dropbox.com/u/1906263/CrashTest.cxx</font><br></div><div><font
class="Apple-style-span" face="times, serif">http://dl.dropbox.com/u/1906263/CMakeLists.txt</font><br></div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">#include "itkImage.h"</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">#include <time.h></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">#include <iostream></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">#include <fstream></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">#include <windows.h></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">#include "itkTextOutput.h"</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">#include "itkImageFileReader.h"</font></div><div><font
class="Apple-style-span" face="times, serif" color="#ff0000">using namespace std;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">typedef itk::Image< unsigned char, 2> ImageType;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">// typedef ImageType::Pointer ImagePtr;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">typedef itk::ImageFileReader< ImageType > ImageReaderType;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000">int main(int argc, char** argv)</font></div><div><font class="Apple-style-span" face="times, serif"
color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>{</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>itk::OutputWindow::SetInstance(itk::TextOutput::New().GetPointer());</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>const std::string refImgName = "file path";</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>ImageReaderType::Pointer ImageReader = ImageReaderType::New();</font></div><div><font class="Apple-style-span" face="times, serif"
color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>ImageReader->DebugOn();</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>ImageReader->SetFileName(refImgName);</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << "reader count at beginning "<<ImageReader->GetReferenceCount() << std::endl;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times,
serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>ImageType::Pointer OutputPointer = ImageType::New();</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>OutputPointer = ImageReader->GetOutput();</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << "reader count after GetOutput " << ImageReader->GetReferenceCount() << std::endl;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << "pointer count
"<<OutputPointer->GetReferenceCount() << std::endl;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>try</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">                </span>{</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">                </span>ImageReader->Update();</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">                </span>}</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span
class="Apple-tab-span" style="white-space:pre">        </span>catch( itk::ExceptionObject & err ) </font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">                </span>{ </font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">                </span>cerr << "ExceptionObject caught in DIR4dvf::ReadImg !" << endl; </font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">                </span>cerr << err << endl; </font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">                </span>throw err;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        
        </span>} </font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << "reader count after update "<<ImageReader->GetReferenceCount() << std::endl;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><br></font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space:pre">        </span>return EXIT_SUCCESS;</font></div><div><font class="Apple-style-span" face="times, serif" color="#ff0000"><span class="Apple-tab-span" style="white-space: pre; ">        </span>}</font></div></div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; "><br></div></font></div></div></div></body></html>