[Insight-users] ITK crash on Lion/Qt

Christian Lackas lackas at invicro.com
Tue Oct 18 11:30:22 EDT 2011


* Christian Lackas <lackas at invicro.com> [111018 15:14]:

Hi Everybody,

just in case this rings a bell for somebody, here a brief description of
what the debugger/stack trace shows.

In itkCurvatureFlowImageFilter.txx:32 the private constructor we have:

     typename CurvatureFlowFunctionType::Pointer cffp;
     cffp = CurvatureFlowFunctionType::New();

Here CurvatureFlowFunctionType::New() seems to return uninitialized
data (the SmartPointer is ok, but the m_Pointer in there is not), and
when trying to assign this to the cffp SmartPointer it crashes, since it
tries to call Register() on the bad m_Pointer.

Looking into what CurvatureFlowFunctionType::New() does, I get down to
ITK's object factory, namely:

    itk::ObjectFactory<itk::CurvatureFlowFunction<itk::Image<float, 2u> >>::Create () at itkObjectFactory.h:52
    52    LightObject::Pointer ret = ObjectFactory::CreateInstance(typeid(T).name());

Unfortunately, ret is 0 and thus the whole problems starts:

    itk::ObjectFactory<itk::CurvatureFlowFunction<itk::Image<float, 2u> >>::Create () at itkObjectFactory.h:53 
    53    return dynamic_cast<T*>(ret.GetPointer());
    (gdb) p ret
    $11 = {
      m_Pointer = 0x0
      }

So why does the ObjectFactory fail here and how can I further debug this
process? Unfortunately, I am completely unfamiliar what ITK does at this
level.

So, still any feedback is highly appreciated.

Christian

-- 
Dr. Christian Lackas, Managing Partner
inviCRO, LLC -- In Imaging Yours
P: +1 617 933 8733, F: +49 2203 9034722, E: lackas at invicro.com
http://www.invicro.com/  http://www.spect-ct.com/

> * Sean McBride <sean at rogue-research.com> [111014 23:46]:
> 
> Hi Sean, Everybody,
> 
> > If you're dying in free() it's probably because of a memory error.
> > You could try enabling MallocScribble and friends (see 'man malloc')
> > and/or guard malloc (see 'man libgmalloc').
> 
> thanks for your suggestions. They gave me a few more ideas on how to
> look at the problem.
> 
> > Does it work if you build in 10.6 and run that executable in 10.7?  If
> > so, it could be related to SDK and deployment target choice.
> 
> It does not matter where it is build. 
> However, thanks to MallocScribble, I now also get it to crash on Snow
> Leopard (which makes development much easier for me, since I have not
> upgraded yet).
> 
> > Is there nothing in the console?  Failures in malloc/free often log something.
> 
> Nothing on the console.
> 
> When trying to understand the source of memory issue, I reduced the
> example to a minimum, basically just a main() with a call like this:
> 
>     PreviewFilterCurvatureType *p = PreviewFilterCurvatureType::New();
> 
> An complete project is available here (just set ITK_DIR env variable to
> your ITK build directory):
> 
>     http://www.invicro.com/vtk/itkcrash.tgz
> 
> If I do (see run.sh):
> 
>     qmake && make clean && make && MallocScribble=1 ./crash.app/Contents/MacOS/crash
> 
> I get this crash:
> 
>     #0  0x000000010000afb6 in itk::SmartPointer<itk::CurvatureFlowFunction<itk::Image<float, 2u> > >::Register (this=0x7fff5fbff040) at itkSmartPointer.h:142
>     #1  0x000000010000b004 in itk::SmartPointer<itk::CurvatureFlowFunction<itk::Image<float, 2u> > >::operator= (this=0x7fff5fbff040, r=0x101510a80) at itkSmartPointer.h:122
>     #2  0x000000010000b04b in itk::SmartPointer<itk::CurvatureFlowFunction<itk::Image<float, 2u> > >::operator= (this=0x7fff5fbff040, r=@0x7fff5fbff050) at itkSmartPointer.h:113
>     #3  0x000000010002114a in itk::CurvatureFlowImageFilter<itk::Image<float, 2u>, itk::Image<float, 2u> >::CurvatureFlowImageFilter (this=0x101510540) at itkCurvatureFlowImageFilter.txx:38
>     #4  0x0000000100021208 in itk::CurvatureFlowImageFilter<itk::Image<float, 2u>, itk::Image<float, 2u> >::New () at itkCurvatureFlowImageFilter.h:100 #5  0x000000010000aa20 in main (argc=1, argv=0x7fff5fbff158) at crash.cxx:15
> 
> Attached below is the output for the LightObject on which it tries to call
> Register(), which seems to be uninitialized.
> 
> Interestingly, it only crashed when using qmake, not when building a
> similar cmake build script. In the end I found that the problem was a
> 
>     export MACOSX_DEPLOYMENT_TARGET = 10.4
> 
> in the qmake produced makefile, and setting this to 10.5 fixed it for
> the small example.
> Can anybody please tell me why it crashes with the 10.4 setting? I was
> not able to figure that part out. I could not figure out how to use
> malloc_history(1), yet.
> 
> Unfortunately, our main application still crashes in the
> PreviewFilterCurvatureType::New(), even with the 10.5 setting, and since
> I believe this is related (although not exactly the same) as the minimal
> example above, I wonder if anybody can give me another pointer on how to
> debug this.
> 
> Sean, could you please try the minimal example and give me a hint on how
> I would debug the actual cause of the problem there?
> 
> Is this a compiler issue? An ITK issue? Or what else?
> 
> Thanks,
>  Christian
> 
> 
> (gdb) p *m_Pointer
> $2 = {
>   <itk::FiniteDifferenceFunction<itk::Image<float, 2u> >> = {
>     <itk::LightObject> = {
>       _vptr$LightObject = 0x5555555555555555, 
>       m_ReferenceCount = 1431655765, 
>       m_ReferenceCountLock = {
>         m_FastMutexLock = {
>           __sig = 6148914691236517205, 
>           __opaque = 'U' <repeats 56 times>
>         }
>       }
>     }, 
>     members of itk::FiniteDifferenceFunction<itk::Image<float, 2u> >: 
>     m_Radius = {
>       m_Size = {6148914691236517205, 6148914691236517205}
>     }, 
>     m_ScaleCoefficients = {1.1945305291614955e+103, 1.1945305291614955e+103}
>   }, 
>   members of itk::CurvatureFlowFunction<itk::Image<float, 2u> >: 
>   m_TimeStep = 1.1945305291614955e+103
> }
> 
> 
> -- 
> Dr. Christian Lackas, Managing Partner
> inviCRO, LLC -- In Imaging Yours
> P: +1 617 933 8733, F: +49 2203 9034722, E: lackas at invicro.com
> http://www.invicro.com/  http://www.spect-ct.com/
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
> 



More information about the Insight-users mailing list