<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div> </div>
<div>Hi Cory, <br></div>
<div dir="ltr"><div> </div>
<div>Sorry that I did not respond earlier. Overlooked your e-mail.<br></div>
<div>Thank you for your reply</div>
<div> </div>
<div>Now using<br></div>
<div> </div>
<div><div style="font-size:12.8px;">OS: Windows 10 x64<br></div>
<div style="font-size:12.8px;">IDE: MS VS 2015 <br></div>
<div style="font-size:12.8px;"><span>VTK</span>: 7.0.0.rc2 x64 build<br></div>
</div>
<div> </div>
<div>Still receiving the same error message at the same place:<br></div>
<div> </div>
<div><div>HEAP CORRUPTION DETECTED: after Normal block (#218683) at 0x00000286C6D22350.<br></div>
<div>CRT detected that the application wrote to memory after end of heap buffer.<br></div>
</div>
<div> </div>
<div>No idea how to create a <span class="size" style="font-size:12.8px">CMakeLists.txt</span><span class="size" style="font-size:12.8px"> file. Please advise.</span><br></div>
<div> </div>
<div>Regards, <br></div>
<div> </div>
<div>Audrius<br></div>
</div>
<div><div> </div>
<div><div>On 8 November 2015 at 15:26, Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com">cory.quammen@kitware.com</a>></span> wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;"><div dir="ltr"><div>Hi Audrius,<br></div>
<div> </div>
<div>That is indeed suspicious. I don't immediately see anything in your code that would explain the crash. Would you mind attaching a compilable example program with accompanying CMakeLists.txt file? That will make it easier to take a look.<br></div>
<div> </div>
<div>Thanks,<br></div>
<div>Cory<br></div>
</div>
<div><div> </div>
<div><div>On Thu, Nov 5, 2015 at 11:19 PM, Audrius Stundzia <span dir="ltr"><<a href="mailto:audrius@tomographix.com">audrius@tomographix.com</a>></span> wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;"><div><u></u><br></div>
<div><div><div>Dear All,<br></div>
<div> </div>
</div>
<div>OS: Windows 10 x64<br></div>
<div>IDE: MS VS 2015 <br></div>
<div>VTK: 6.3.0 x64 build<br></div>
<div><div> </div>
<div>I am getting a "heap corruption" message when a vtkRenderWindow is closed and the vtkRenderWindowInteractor is stopped.<br></div>
<div>Specifically the line <br></div>
<div> </div>
<div><span style="line-height:10.8333px;">renderWindowInteractor->TerminateApp();</span><br></div>
<div> </div>
<div>in a callback function<br></div>
<div> </div>
<div><span style="line-height:10.8333px;">static void KeyPressCallbackFunction</span><br></div>
<div> </div>
<div>The relevant code fragments, appended below, are conventional texture mapping of an image to a plane.<br></div>
<div>This "heap corruption" did not occur in Windows 8.1 x64; MS VS 2010; VTK 5.10.1 x64 build<br></div>
<div> </div>
<div>From the call stack it appears to due to a problem with deleting an instantiation of vtkLoopupTable:<br></div>
<div> </div>
</div>
<div>vtkCommonCore-6.3.dll!vtkDataArrayTemplate<unsigned char>::DeleteArray() Line 214 C++<br></div>
<div>vtkCommonCore-6.3.dll!vtkDataArrayTemplate<unsigned char>::~vtkDataArrayTemplate<unsigned char>() Line 92 C++<br></div>
<div>vtkCommonCore-6.3.dll!vtkUnsignedCharArray::~vtkUnsignedCharArray() Line 37 C++<br></div>
<div>[External Code]<br></div>
<div>vtkCommonCore-6.3.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase * __formal, int check) Line 232 C++<br></div>
<div>vtkCommonCore-6.3.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o, int check) Line 901 C++<br></div>
<div>vtkCommonCore-6.3.dll!vtkObjectBase::UnRegister(vtkObjectBase * o) Line 190 C++<br></div>
<div>vtkCommonCore-6.3.dll!vtkLookupTable::~vtkLookupTable() Line 89C++<br></div>
<div>[External Code]<br></div>
<div>vtkCommonCore-6.3.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase * __formal, int check) Line 232 C++<br></div>
<div>vtkCommonCore-6.3.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o, int check) Line 901 C++<br></div>
<div>vtkCommonCore-6.3.dll!vtkObjectBase::UnRegister(vtkObjectBase * o) Line 190 C++<br></div>
<div>vtkCommonCore-6.3.dll!vtkSmartPointerBase::~vtkSmartPointerBase() Line 62 C++<br></div>
<div>[External Code]<br></div>
<div> </div>
<div>Any insight would be appreciated.<br></div>
<div> </div>
<div>Regards, <br></div>
<div> </div>
<div>Audrius<br></div>
<div> </div>
<div>//---------------------------------------<br></div>
<div><span style="line-height:1.25;">// Start: relevant code fragment</span><br></div>
<div>//---------------------------------------<br></div>
<div> </div>
<div>{<br></div>
<div>. . .<br></div>
<div> </div>
<div><span style="line-height:10.8333px;">vtkSmartPointer<vtkCamera> </span>camera_ = <span style="line-height:10.8333px;">vtkSmartPointer<vtkCamera>::New();</span><br></div>
<div> </div>
<div>camera_->SetPosition( 0.0, 0.0, -1.0);<br></div>
<div>camera_->SetRoll(180.0);<br></div>
<div> </div>
<div>camera_->Zoom( zoomFactor_ );<br></div>
<div> </div>
<div><span style="line-height:10.8333px;">//---------------</span><br></div>
<div><span style="line-height:10.8333px;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkRenderer> </span>renderer_ = vtkSmartPointer<vtkRenderer>::New();</span><br></div>
<div><span style="line-height:10.8333px;">renderer_->SetActiveCamera(camera_);</span><br></div>
<div><span style="line-height:10.8333px;">renderer_->SetBackground( 0.0, 0.0, 0.0 );</span><br></div>
<div> </div>
<div><span style="line-height:10.8333px;">//---------------</span><br></div>
<div><span style="line-height:10.8333px;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkRenderWindow> </span>renderWindow_ = vtkSmartPointer<vtkRenderWindow>::New();</span><br></div>
<div><span style="line-height:10.8333px;">renderWindow_->AddRenderer( renderer_ );</span><br></div>
<div><span style="line-height:10.8333px;">renderWindow_->SetSize</span><br></div>
<div><span style="line-height:10.8333px;">( winSizeX_</span><br></div>
<div><span style="line-height:10.8333px;">, winSizeY_ );</span><br></div>
<div><span style="line-height:10.8333px;">renderWindow_->SetPosition</span><br></div>
<div><span style="line-height:10.8333px;">( winPosX_</span><br></div>
<div><span style="line-height:10.8333px;">, winPosY_ );</span><br></div>
<div><span style="line-height:10.8333px;">renderWindow_->SwapBuffersOn();</span><br></div>
<div> </div>
<div><span style="line-height:10.8333px;">//---------------</span><br></div>
<div><span style="line-height:10.8333px;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkRenderWindowInteractor> </span>renderWindowInteractor_ = vtkSmartPointer<vtkRenderWindowInteractor>::New();</span><br></div>
<div><span style="line-height:10.8333px;">renderWindowInteractor_->SetRenderWindow( renderWindow_);    </span><br></div>
<div> </div>
<div><span style="line-height:10.8333px;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkCallbackCommand> </span>keyPressCallback_ = vtkSmartPointer<vtkCallbackCommand>::New();</span><br></div>
<div><span style="line-height:10.8333px;">keyPressCallback_->SetCallback( advDiagnosticDisplay::KeyPressCallbackFunction);</span><br></div>
<div> </div>
<div><span style="line-height:10.8333px;">renderWindowInteractor_->AddObserver</span><br></div>
<div><span style="line-height:10.8333px;">( vtkCommand::KeyPressEvent</span><br></div>
<div><span style="line-height:10.8333px;">, keyPressCallback_ );</span><br></div>
<div><div> </div>
<div><div><div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>// Build a colour map<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkLookupTable> </span></span>colourMap_ = vtkSmartPointer<vtkLookupTable>::New();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>InitializeColourMap(colourMap_);<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>// Apply the texture<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkTexture> </span></span>texture_ = vtkSmartPointer<vtkTexture>::New();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>if(interpolation_) <br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>texture_->InterpolateOn();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>else<span style="white-space:pre-wrap;"></span> <br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>texture_->InterpolateOff();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>texture_->RepeatOff();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>texture_->SetQualityTo32Bit();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>texture_->MapColorScalarsThroughLookupTableOn();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>texture_->SetInputData( imageReslice_->GetOutput());<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>texture_->SetLookupTable( colourMap_);<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>//---------------<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkPlaneSource> </span></span>planeSource_ = vtkSmartPointer<vtkPlaneSource>::New();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>planeSource_->SetResolution( 1, 1 );<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>planeSource_->SetPoint1( eX_, 0.0, 0.0);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>planeSource_->SetPoint2( 0.0, eY_, 0.0);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>planeSource_->SetCenter( centre_.data());<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>planeSource_->SetNormal( 0.0, 0.0, 1.0);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>planeSource_->Update();<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>//---------------<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkPolyDataMapper> </span></span>mapper_ = vtkSmartPointer<vtkPolyDataMapper>::New();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>mapper_->ScalarVisibilityOff(); <br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>mapper_->SetInputData( planeSource_->GetOutput());<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>mapper_->Update();<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>//---------------<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkProperty> </span></span>property_ = vtkSmartPointer<vtkProperty>::New();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>property_->SetOpacity( opacity_);<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>//---------------<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span style="line-height:10.8333px;">vtkSmartPointer<vtkActor> </span></span>actor_ = vtkSmartPointer<vtkActor>::New();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>actor_->SetProperty( property_ );<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>actor_->SetTexture( texture_ );<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>actor_->SetMapper( mapper_ );<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>//---------------<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>renderer_->AddActor(actor_);<br></div>
<div style="line-height:10.8333px;"> </div>
</div>
<div>renderer_->ResetCamera();<br></div>
</div>
</div>
<div> </div>
<div>renderWindow_->Render();<br></div>
<div>renderWindow_->SetWindowName( "Window name here");<br></div>
<div> </div>
<div>renderWindowInteractor_->Start();<br></div>
<div> </div>
<div><div><div><div><div><span style="line-height:10.8333px;">. . .</span><br></div>
<div> </div>
<div><span style="line-height:10.8333px;">}</span><br></div>
</div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>void InitializeColourMap(vtkSmartPointer<vtkLookupTable>& colourMap)<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>{<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>//---------------<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->SetNumberOfColors(nImageColours_ + 1);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->SetTableRange<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>(minScalar_<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, maxScalar_);<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>if (colour_)<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>{<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->SetHueRange(0.666667f, 0.0f);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->Build();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->SetTableValue(0, 0.0f, 0.0f, 0.0f, 0.0f);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>}<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>else<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>{<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->SetHueRange(0.5f, 0.5f);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->SetSaturationRange(0.0f, 1.0f);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->Build();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->SetTableValue(0, 0.0f, 0.0f, 0.0f, 0.0f);<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>for (int iC = 1; iC <= nImageColours_; ++iC)<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>{<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>const float val = static_cast<float>(iC) / static_cast<float>(nImageColours_ + 1);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>colourMap->SetTableValue<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>(iC<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, val<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, val<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, val<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, 1.0f);<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>}<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>}<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>}<br></div>
<div style="line-height:10.8333px;"> </div>
</div>
</div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="line-height:10.8333px;white-space:pre-wrap;"></span><span style="line-height:10.8333px;">// </span><br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>// vtk callback function: stop rendering and close window<br></div>
<div style="line-height:10.8333px;"><span style="line-height:10.8333px;white-space:pre-wrap;"></span><span style="line-height:10.8333px;">// </span><br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>static void KeyPressCallbackFunction<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>( vtkObject* caller<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, long unsigned int vtkNotUsed(eventId)<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, void* vtkNotUsed(clientData)<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, void* vtkNotUsed(callData))<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>{<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>vtkRenderWindowInteractor* renderWindowInteractor = dynamic_cast<vtkRenderWindowInteractor*>(caller);<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="line-height:10.8333px;white-space:pre-wrap;"></span>// Close the window<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>vtkRenderWindow* renderWindow = renderWindowInteractor->GetRenderWindow();<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>renderWindow->Finalize();<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>// Stop the interactor<br></div>
<div style="line-height:10.8333px;"><span style="line-height:10.8333px;white-space:pre-wrap;"></span>// When the next line is executed, the heap corruption message is generated<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>renderWindowInteractor->TerminateApp();<br></div>
<div style="line-height:10.8333px;"> </div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>std::cout << "Window closed." << std::endl;<br></div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>}<br></div>
</div>
</div>
<div> </div>
<div> </div>
<div> </div>
</div>
<div> </div>
<div>_______________________________________________<br></div>
<div>
Powered by <a href="http://www.kitware.com">www.kitware.com</a><br></div>
<div> </div>
<div>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br></div>
<div> </div>
<div>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br></div>
<div> </div>
<div>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a><br></div>
<div> </div>
<div>
Follow this link to subscribe/unsubscribe:<br></div>
<div> <a href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a><br></div>
<div> </div>
</blockquote></div>
<div><span><span class="colour" style="color:rgb(136, 136, 136)"><br><br clear="all"></span></span></div>
<div> </div>
<div><span><span class="colour" style="color:rgb(136, 136, 136)">-- <br></span></span></div>
<div><span><span class="colour" style="color:rgb(136, 136, 136)">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</span></span></div>
<div> </div>
</div>
</blockquote></div>
</div>
<div> </div>
</body>
</html>