[Insight-users] Cannot access LightObject functions in object instantiated in DLL

Cory Quammen cquammen at cs.unc.edu
Wed May 12 07:33:27 EDT 2010


This line

>    std::cout << filt->tralalie() << "\n";           // Fine....

May be causing a problem.

In your function

>    char * tralalie() {return "In itkImageToVTKImageFilter.h";}

Here you are allocating a character array on the stack which is
deallocated as soon as tralalie() returns. When you print out the
return value from tralalie(), std::cout steps through the now-invalid
memory. It probably works well enough to fool you into thinking it
works, but it could be corrupting memory in a way that doesn't show up
until you call

std::cout << filt->GetReferenceCount() << "\n";    // Crash with

Try removing the call to filt-tralalie() and see if that fixes your problem.

Hope that helps,
Cory

-- 
Cory Quammen
Center for Computer Integrated Systems for Microscopy and Manipulation (CISMM)
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen


More information about the Insight-users mailing list