[ITK] Segmentation Fault at SpatialObject::New()

Jinwoo Choi jinwoo.choi at mail.utoronto.ca
Thu May 1 14:24:07 EDT 2014


Dear all,

I have the following simple code:

#include <itkSpatialObject.h>
int main(int argc, char *argv[])
{
   typedef itk::SpatialObject<2> SOT;
   while (true) {
     SOT::Pointer sot = SOT::New();
   }
}

Which results in a segmentation fault with the following stack trace:

#0  0x00007fff8986bce2 in __pthread_kill ()
#1  0x00007fff8dd237d2 in pthread_kill ()
#2  0x00007fff8dd14a7a in abort ()
#3  0x00007fff8dd7384c in free ()
#4  0x00000001093c2f69 in itk::LightObject::~LightObject 
(this=0x115f00370) at 
/Users/jin/MyVTK/ITK/ITK/Modules/Core/Common/src/itkLightObject.cxx:254
#5  0x00000001093c2e7e in itk::LightObject::UnRegister 
(this=0x115f00370) at 
/Users/jin/MyVTK/ITK/ITK/Modules/Core/Common/src/itkLightObject.cxx:206
#6  0x0000000100038e14 in 
itk::SmartPointer<itk::VectorContainer<unsigned long, itk::Point<double, 
2u> > >::UnRegister (this=0x7fff5fbff7b0) at itkSmartPointer.h:157
#7  0x0000000100038dc9 in 
itk::SmartPointer<itk::VectorContainer<unsigned long, itk::Point<double, 
2u> > >::~SmartPointer (this=0x7fff5fbff7b0) at itkSmartPointer.h:65
#8  0x0000000100038da5 in 
itk::SmartPointer<itk::VectorContainer<unsigned long, itk::Point<double, 
2u> > >::~SmartPointer (this=0x7fff5fbff7b0) at itkSmartPointer.h:64
#9  0x000000010004cc04 in itk::BoundingBox<unsigned long, 2, double, 
itk::VectorContainer<unsigned long, itk::Point<double, 2u> > 
 >::BoundingBox (this=0x115f00270) at itkBoundingBox.hxx:124
#10 0x000000010004cb15 in itk::BoundingBox<unsigned long, 2, double, 
itk::VectorContainer<unsigned long, itk::Point<double, 2u> > 
 >::BoundingBox (this=0x115f00270) at itkBoundingBox.h:125
#11 0x0000000100028982 in itk::BoundingBox<unsigned long, 2, double, 
itk::VectorContainer<unsigned long, itk::Point<double, 2u> > >::New () 
at itkBoundingBox.h:90
#12 0x0000000100028097 in itk::SpatialObject<2u>::SpatialObject 
(this=0x115f00000) at itkSpatialObject.hxx:35
#13 0x0000000100027e35 in itk::SpatialObject<2u>::SpatialObject 
(this=0x115f00000) at itkSpatialObject.h:57
#14 0x0000000100027b32 in itk::SpatialObject<2u>::New () at 
itkSpatialObject.h:137
#15 0x00000001000279df in main (argc=1, argv=0x7fff5fbffb30) at 
/Users/jin/vurtigo/rtMain.cpp:64
#16 0x0000000100027924 in start ()

I have this issue with ITK4.2.1 and ITK 4.5.2, happens both Debug and 
Release compilation.

Oddly, when I put a break point on (using gdb) itkSpatialObject.h:57 and 
print m_Bounds, delete all break points, and continue (continue in the 
main while loop), the segmentation fault stops occurring.

My platform is OSX 10.7.5, and I am using /usr/bin/c++ (which I believe 
is clang), clang -v -version outputs the following:
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

Any insights into this issue will be greatly appreciated!

Thank you,

Jin


More information about the Community mailing list