View Issue Details

IDProjectCategoryView StatusLast Update
0003071Slicer4Module BRAINSpublic2015-11-30 17:41
Reporterpohl Assigned Topieper  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSUbuntu 64 bitOS Version12.04
Product Version 
Target VersionSlicer 4.3.0Fixed in VersionSlicer 4.4.0 
Summary0003071: Brainsfit crashes
Description

From: Steve Pieper <pieper@ibility.net>
Reply-To: "pieper@bwh.harvard.edu" <pieper@bwh.harvard.edu>
Date: Friday, April 5, 2013 3:34 PM
To: Hans Johnson <hans-johnson@uiowa.edu>
Cc: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>, Kilian Pohl <pohl.kilian@gmail.com>, Ron Kikinis <kikinis@bwh.harvard.edu>
Subject: Re: Test relying on Brainsfit fail

Hi Hans -

It's easy to replicate:

  • Go to SampleData module
  • download MRHead
  • download Baseline volume
  • try to register

These volumes overlap (see attached image) but I still get the crash on mac.

-Steve

Additional Information

/software/Slicer4/superbuild/Slicer-build/lib/Slicer-4.2/cli-modules//BRAINSFit" --backgroundFillValue 0.0 --interpolationMode Linear --outputVolumePixelType float --fixedVolume "/tmp/EMS384217548mMX5QS_vtkMRMLScalarVolumeNode23.nrrd" --movingVolume "/tmp/EMS1585913069YlN6ym_vtkMRMLScalarVolumeNode20.nrrd" --outputVolume "/tmp/EMS254363168ecUniQ_vtkMRMLScalarVolumeNode29.nrrd" --bsplineTransform "/tmp/EMS69163220202VW1j_vtkMRMLBSplineTransformNode1.mat" --numberOfIterations 3 --numberOfSamples 100 --useRigid --useScaleSkewVersor3D --useAffine --useBSpline --splineGridSize 6,6,6 --maxBSplineDisplacement 0 --useCachingOfBSplineWeightsMode ON --initializeTransformMode useCenterOfHeadAlign --minimumStepLength 0.005 --translationScale 1000 --reproportionScale 1 --skewScale 1 --maskProcessingMode NOMASK --numberOfHistogramBins 40 --numberOfMatchPoints 10 --costMetric MMI --fixedVolumeTimeIndex 0 --movingVolumeTimeIndex 0 --debugNumberOfThreads -1 --debugLevel 0 --failureExitCode -1
369: Error executing __tpycl_result = slicer.DeeNNvUZ.PrintText('TCL: Long flag "--debugNumberOfThreads" is deprecated. Please use long flag "--numberOfThreads" instead.
Original Fixed image origin[119.53, 92.25, 119.53, 0]
TranformTypes: Rigid(1 of 4).

TranformTypes: ScaleSkewVersor3D(2 of 4).

TranformTypes: Affine(3 of 4).

TranformTypes: BSpline(4 of 4).

Initializing transform with useCenterOfHeadAlign
ListSample TotalFrequency is 20700
221 ValidHistogramsEntries, 20700 TotalFrequency
0.001 ---> 0
0.999 ---> 216
LowHigh Thresholds: [44,-2147483648]
maxSIDirection = 116
Computing Sampled Distance Computations
ListSample TotalFrequency is 126976
273 ValidHistogramsEntries, 126976 TotalFrequency
0.001 ---> 0
0.999 ---> 219
LowHigh Thresholds: [47,-2147483648]
maxSIDirection = 119.53
Computing Sampled Distance Computations
Initializing transform with useCenterOfHeadAlign to
VersorRigid3DTransform (0x2563ec0)
RTTI typeinfo: itk::VersorRigid3DTransform<double>
Reference Count: 2
Modified Time: 3246
Debug: Off
Observers:
none
Matrix:
0.99863 0.0522642 -0.00273905
-0.052336 0.997261 -0.0522642
-6.50521e-19 0.052336 0.99863
Offset: [-3.243, -4.28128, -3.09062]
Center: [0.512167, -4.43833, -5.68979]
Translation: [-3.46008, -3.99856, -3.3151]
Inverse:
0.99863 -0.052336 -6.50521e-19
0.0522642 0.997261 0.052336
-0.00273905 -0.0522642 0.99863
Singular: 0
Versor: [ 0.026168, -0.000685233, -0.026168, 0.999315 ]

===============================================

=============================== Starting Transform Estimations for Rigid(1 of 4).===============================

WARNING USING MAX MMI NUMBER OF THREADS: -1
Initializer, optimizerScales: [1, 1, 1, 0.001, 0.001, 0.001].
METRIC THREADS USED: 1 of 1
REGISTRATION THREADS USED: 1 of 1
terminate called after throwing an instance of 'itk::ExceptionObject'
what(): /software/Slicer4/superbuild/BRAINSTools/BRAINSCommonLib/BRAINSFitHelperTemplate.hxx:617:
itk::ERROR: Exception caught during registration:
itk::ExceptionObject (0x269ab20)
Location: "void itk::MattesMutualInformationImageToImageMetric<TFixedImage, TMovingImage>::GetValueAndDerivative(const ParametersType&, itk::MattesMutualInformationImageToImageMetric<TFixedImage, TMovingImage>::MeasureType&, itk::MattesMutualInformationImageToImageMetric<TFixedImage, TMovingImage>::DerivativeType&) const [with TFixedImage = itk::Image<float, 3u>; TMovingImage = itk::Image<float, 3u>; itk::MattesMutualInformationImageToImageMetric<TFixedImage, TMovingImage>::ParametersType = itk::OptimizerParameters<double>; itk::MattesMutualInformationImageToImageMetric<TFixedImage, TMovingImage>::MeasureType = double; itk::MattesMutualInformationImageToImageMetric<TFixedImage, TMovingImage>::DerivativeType = itk::Array<double>]"
File: /software/Slicer4/superbuild/ITKv4/Modules/Registration/Common/include/itkMattesMutualInformationImageToImageMetric.hxx
Line: 821
Description: itk::ERROR: MattesMutualInformationImageToImageMetric(0x2563970): Joint PDF summed to zero

TagsNo tags attached.

Relationships

has duplicate 0003050 closedjcfr BRAINSFit -> crash 

Activities

pohl

pohl

2013-04-16 17:05

developer   ~0008419

Hans:

This is really disturbing. I spent many hours this weekend tracking down the problem, and it is really weird.

It seems to be failing differently on different computers/compilers, so I am looking into a valgrind build to see if some memory corruption is occurring.

When debugging I have the equivalent of:

std::cout << "PRE: " << LBFSGBoptimizer->GetUpperBound().size() << " " << localUpperBound.size() << std::endl;
#PRE: 0 9645
LBFSGBoptimizer->SetUpperBound(localUpperBound);

std::cout << "POST: " << LBFSGBoptimizer->GetUpperBound().size() << " " << localUpperBound.size() << std::endl;
#POST: 0 9645 <----- THIS IS WRONG!!! it should be POST: 9645 9645

=========
When I step into the SetUpperBound function with the debugger, m_UpperBound = localUpperBound seems to work and does set the values of m_UpperBound inside the function, but as soon as it returns, the optimizer->GetUpperBound().size() is not correct.

==========

This is passing on all stand-alone static builds of BRAINSTools, but the internal slicer build is failing.

==========

I'll continue to work on it this week, but it seems like a bigger nastier problem than a bug in BRAINSFit alone.

Hans

From: Steve Pieper <pieper@ibility.net>

I just tried the current nightly build and got the same crash as yesterday when running registration.

It's clearly something still screwed up with the IO factories and linking - the stack below should never happen:

Thread 4 Crashed:
0 libITKIOHDF5-4.4.1.dylib 0x000000010339fc08 std::vector<double, std::allocator<double> >::operator=(std::vector<double, std::allocator<double> > const&) + 56
1 libvtkSlicerEMSegmentModuleLogic.dylib0x0000000117ad0269 itk::MattesMutualInformationImageToImageMetric<itk::Image<float, 3u>, itk::Image<float, 3u> >::GetValueAndDerivativeThreadPreProcess(unsigned int, bool) const + 105
2 libBRAINSFitEZLib.dylib 0x000000011df416ed itk::BRAINSFitHelper::Update() + 557
3 libBRAINSFitEZLib.dylib 0x000000011ddeff41 ModuleEntryPoint + 74417
4 libqSlicerBaseQTCLI.dylib 0x0000000100227e11 vtkSlicerCLIModuleLogic::ApplyTask(void) + 32545
5 libSlicerBaseLogic.dylib 0x00000001030a064f vtkSlicerApplicationLogic::ProcessProcessingTasks() + 127
6 libSlicerBaseLogic.dylib 0x00000001030a07af vtkSlicerApplicationLogic::ProcessingThreaderCallback(void
) + 31
7 libsystem_c.dylib 0x00007fff8fa518bf _pthread_start + 335
8 libsystem_c.dylib 0x00007fff8fa54b75 thread_start + 13

On Sat, Apr 6, 2013 at 9:12 AM, Johnson, Hans J <hans-johnson@uiowa.edu> wrote:

This is weird.

Inside of Slicer build tree, I make a separate LOCAL_BRAINSTools-build directory and I build a separate build tree FROM THE SAME SOURCE TREE USED BY SLICER!  

My build ( a Static Build) works, Slicer build of the same source code ( a shared lib build)  fails with a weird exception about a variable that is not initialized.

Hans
pieper

pieper

2013-04-21 15:26

administrator   ~0008456

Okay - we'll, I did a little experimenting and found out what is up. Do I win a prize? ;D

It turns out that the BRAINSTools build turns on ITK_FUTURE_LEGACY_REMOVE [1] but slicer's ITK build turns it off. The impact of this flag [3] is to disable certain methods, so now it makes some sense why code compiled with the legacy methods removed would have incorrect virtual function pointers when linked against libraries where the legacy methods existed.

If BRAINSFit requires this flag to be set, then it should probably refuse to compile against a version of ITK where the flag was not set.

As a side complication, turning off the legacy code also means you cannot turn on ITKV3_COMPATIBILITY, which slicer currently needs in order to build.

The best way forward is probably for us to move slicer's code entirely to ITKv4 and turn off the legacy and v3 compatibility features from the build.

I suggest we look at this next at the slicer hangout.

[1] https://github.com/BRAINSia/BRAINSTools/blob/master/Common.cmake#L176

[2] https://github.com/Slicer/Slicer/blob/master/SuperBuild/External_ITKv4.cmake#L97

[3] https://github.com/Kitware/ITK/blob/master/Modules/Core/Common/include/itkMacro.h#L401

pieper

pieper

2013-04-22 05:26

administrator   ~0008457

Here's a fix that works for me after a rebuild:

https://github.com/BRAINSia/BRAINSTools/pull/26

hjmjohnson

hjmjohnson

2013-04-22 13:00

developer   ~0008458

commit ea67a47cc5a2f043c4d24e167335a6ccd5bab963
Author: hjohnson <hjohnson@3bd1e089-480b-0410-8dfb-8563597acbee>
Date: Mon Apr 22 20:52:09 2013 +0000

ENH: Reset BRAINSTools to build without the ITK_FUTURE_LEGACY_REMOVE

The inconsistent use of ITK_FUTURE_LEGACY_REMOVE was causing major runtime
errors with regards to virtual functions being located in different places
in the object files between compilation units.

This update also turns off many new tools that are not ready for
distribution with Slicer.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21906 3bd1e089-480b-0410-8dfb-8563597acbee

=====

In addition, a patch set is being reviewed for ITKv4 that will make using the ITK_FUTURE_LEGACY_REMOVE feature easier to use.

jcfr

jcfr

2014-03-06 05:15

administrator   ~0011067

Closing resolved issues that have not been updated in more than 3 months

Issue History

Date Modified Username Field Change
2013-04-16 17:04 pohl New Issue
2013-04-16 17:04 pohl Status new => assigned
2013-04-16 17:04 pohl Assigned To => hjmjohnson
2013-04-16 17:05 pohl Note Added: 0008419
2013-04-16 17:11 pohl Assigned To hjmjohnson => jcfr
2013-04-21 15:26 pieper Note Added: 0008456
2013-04-22 05:26 pieper Note Added: 0008457
2013-04-22 06:38 jcfr Assigned To jcfr => pieper
2013-04-22 13:00 hjmjohnson Note Added: 0008458
2013-04-22 13:00 hjmjohnson Status assigned => resolved
2013-04-22 13:00 hjmjohnson Resolution open => fixed
2013-04-23 03:46 pieper Relationship added has duplicate 0003050
2014-03-06 05:15 jcfr Note Added: 0011067
2014-03-06 05:17 jcfr Status resolved => closed
2014-03-06 05:54 jcfr Fixed in Version => Slicer 4.4.0
2015-11-30 17:41 jcfr Category Module BRAINSFit => Module BRAINS