[vtkusers] Fwd: Re: Heap corruption | vtkLookupTable?

Audrius Stundzia audrius at tomographix.com
Wed Jan 27 16:15:58 EST 2016


Hi Cory,

Sorry that I did not respond earlier. Overlooked your e-mail. Thank you
for your reply

Now using

OS: Windows 10 x64 IDE: MS VS 2015 VTK: 7.0.0.rc2 x64 build

Still receiving the same error message at the same place:

HEAP CORRUPTION DETECTED: after Normal block (#218683) at
0x00000286C6D22350. CRT detected that the application wrote to memory
after end of heap buffer.

No idea how to create a CMakeLists.txt file. Please advise.

Regards,

Audrius

On 8 November 2015 at 15:26, Cory Quammen <cory.quammen at kitware.com> wrote:
> Hi Audrius,
>
> 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.
>
> Thanks, Cory
>
> On Thu, Nov 5, 2015 at 11:19 PM, Audrius Stundzia
> <audrius at tomographix.com> wrote:
>> __
>> Dear All,
>>
>> OS: Windows 10 x64 IDE: MS VS 2015 VTK: 6.3.0 x64 build
>>
>> I am getting a "heap corruption" message when a vtkRenderWindow is
>> closed and the vtkRenderWindowInteractor is stopped. Specifically
>> the line
>>
>> renderWindowInteractor->TerminateApp();
>>
>> in a callback function
>>
>> static void KeyPressCallbackFunction
>>
>> The relevant code fragments, appended below, are conventional texture
>> mapping of an image to a plane. This "heap corruption" did not occur
>> in Windows 8.1 x64; MS VS 2010; VTK 5.10.1 x64 build
>>
>> From the call stack it appears to due to a problem with deleting an
>> instantiation of vtkLoopupTable:
>>
>> vtkCommonCore-6.3.dll!vtkDataArrayTemplate<unsigned
>> char>::DeleteArray() Line 214 C++ vtkCommonCore-
>> 6.3.dll!vtkDataArrayTemplate<unsigned
>> char>::~vtkDataArrayTemplate<unsigned char>() Line 92 C++ vtkCommonCore-
>> 6.3.dll!vtkUnsignedCharArray::~vtkUnsignedCharArray() Line 37 C++
>> [External Code] vtkCommonCore-
>> 6.3.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase * __formal,
>> int check) Line 232 C++ vtkCommonCore-
>> 6.3.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o, int check)
>> Line 901 C++ vtkCommonCore-
>> 6.3.dll!vtkObjectBase::UnRegister(vtkObjectBase * o) Line 190 C++ vtkCommonCore-
>> 6.3.dll!vtkLookupTable::~vtkLookupTable() Line 89C++ [External Code]
>> vtkCommonCore-6.3.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase
>> * __formal, int check) Line 232 C++ vtkCommonCore-
>> 6.3.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o, int check)
>> Line 901 C++ vtkCommonCore-
>> 6.3.dll!vtkObjectBase::UnRegister(vtkObjectBase * o) Line 190 C++ vtkCommonCore-
>> 6.3.dll!vtkSmartPointerBase::~vtkSmartPointerBase() Line 62 C++
>> [External Code]
>>
>> Any insight would be appreciated.
>>
>> Regards,
>>
>> Audrius
>>
>> //--------------------------------------- // Start: relevant code
>> fragment //---------------------------------------
>>
>> {
>> . . .
>>
>> vtkSmartPointer<vtkCamera> camera_ =
>> vtkSmartPointer<vtkCamera>::New();
>>
>> camera_->SetPosition( 0.0, 0.0, -1.0); camera_->SetRoll(180.0);
>>
>> camera_->Zoom( zoomFactor_ );
>>
>> //--------------- vtkSmartPointer<vtkRenderer> renderer_ =
>> vtkSmartPointer<vtkRenderer>::New(); renderer_-
>> >SetActiveCamera(camera_); renderer_->SetBackground( 0.0, 0.0, 0.0 );
>>
>> //--------------- vtkSmartPointer<vtkRenderWindow> renderWindow_ =
>> vtkSmartPointer<vtkRenderWindow>::New(); renderWindow_->AddRenderer(
>> renderer_ ); renderWindow_->SetSize ( winSizeX_ , winSizeY_ ); renderWindow_-
>> >SetPosition ( winPosX_ , winPosY_ ); renderWindow_->SwapBuffersOn();
>>
>> //--------------- vtkSmartPointer<vtkRenderWindowInteractor>
>> renderWindowInteractor_ =
>> vtkSmartPointer<vtkRenderWindowInteractor>::New();    renderWindowInteractor_-
>> >SetRenderWindow( renderWindow_);
>>
>> vtkSmartPointer<vtkCallbackCommand> keyPressCallback_ =
>> vtkSmartPointer<vtkCallbackCommand>::New(); keyPressCallback_-
>> >SetCallback( advDiagnosticDisplay::KeyPressCallbackFunction);
>>
>> renderWindowInteractor_->AddObserver ( vtkCommand::KeyPressEvent ,
>> keyPressCallback_ );
>>
>> // Build a colour map vtkSmartPointer<vtkLookupTable> colourMap_ =
>> vtkSmartPointer<vtkLookupTable>::New();
>> InitializeColourMap(colourMap_);
>>
>> // Apply the texture vtkSmartPointer<vtkTexture> texture_ =
>> vtkSmartPointer<vtkTexture>::New(); if(interpolation_) texture_-
>> >InterpolateOn(); else texture_->InterpolateOff(); texture_-
>> >RepeatOff(); texture_->SetQualityTo32Bit(); texture_-
>> >MapColorScalarsThroughLookupTableOn(); texture_->SetInputData( imageReslice_-
>> >GetOutput()); texture_->SetLookupTable( colourMap_);
>>
>> //--------------- vtkSmartPointer<vtkPlaneSource> planeSource_ =
>> vtkSmartPointer<vtkPlaneSource>::New(); planeSource_->SetResolution(
>> 1, 1 ); planeSource_->SetPoint1( eX_, 0.0, 0.0); planeSource_-
>> >SetPoint2( 0.0, eY_, 0.0); planeSource_->SetCenter( centre_.data());
>> planeSource_->SetNormal( 0.0, 0.0, 1.0); planeSource_->Update();
>>
>> //--------------- vtkSmartPointer<vtkPolyDataMapper> mapper_ =
>> vtkSmartPointer<vtkPolyDataMapper>::New(); mapper_-
>> >ScalarVisibilityOff(); mapper_->SetInputData( planeSource_-
>> >GetOutput()); mapper_->Update();
>>
>> //--------------- vtkSmartPointer<vtkProperty> property_ =
>> vtkSmartPointer<vtkProperty>::New(); property_->SetOpacity(
>> opacity_);
>>
>> //--------------- vtkSmartPointer<vtkActor> actor_ =
>> vtkSmartPointer<vtkActor>::New(); actor_->SetProperty( property_ );
>> actor_->SetTexture( texture_ ); actor_->SetMapper( mapper_ );
>>
>> //--------------- renderer_->AddActor(actor_);
>>
>> renderer_->ResetCamera();
>>
>> renderWindow_->Render(); renderWindow_->SetWindowName( "Window name
>> here");
>>
>> renderWindowInteractor_->Start();
>>
>> . . .
>>
>> }
>>
>> void InitializeColourMap(vtkSmartPointer<vtkLookupTable>& colourMap)
>> { //--------------- colourMap->SetNumberOfColors(nImageColours_ + 1);
>> colourMap->SetTableRange (minScalar_ , maxScalar_);
>>
>> if (colour_) { colourMap->SetHueRange(0.666667f, 0.0f); colourMap-
>> >Build(); colourMap->SetTableValue(0, 0.0f, 0.0f, 0.0f, 0.0f); } else
>> { colourMap->SetHueRange(0.5f, 0.5f); colourMap-
>> >SetSaturationRange(0.0f, 1.0f); colourMap->Build(); colourMap-
>> >SetTableValue(0, 0.0f, 0.0f, 0.0f, 0.0f);
>>
>> for (int iC = 1; iC <= nImageColours_; ++iC) { const float val =
>> static_cast<float>(iC) / static_cast<float>(nImageColours_ + 1); colourMap-
>> >SetTableValue (iC , val , val , val , 1.0f); } } }
>>
>>
>> // // vtk callback function: stop rendering and close window //
>>
>> static void KeyPressCallbackFunction ( vtkObject* caller , long
>> unsigned int vtkNotUsed(eventId) , void* vtkNotUsed(clientData) ,
>> void* vtkNotUsed(callData)) { vtkRenderWindowInteractor*
>> renderWindowInteractor =
>> dynamic_cast<vtkRenderWindowInteractor*>(caller);
>>
>> // Close the window vtkRenderWindow* renderWindow = renderWindowInteractor-
>> >GetRenderWindow(); renderWindow->Finalize();
>>
>> // Stop the interactor // When the next line is executed, the heap
>> corruption message is generated renderWindowInteractor-
>> >TerminateApp();
>>
>> std::cout << "Window closed." << std::endl; }
>>
>>
>>
>>
>> _______________________________________________
>>
Powered by www.kitware.com
>>
>>
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
>>
>>
Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
>>
>>
Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>>
Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
>
> --
> Cory Quammen R&D Engineer Kitware, Inc.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160127/9e1ab59b/attachment.html>


More information about the vtkusers mailing list