Documentation/Labs/BRAINS and ITKv4 issue
This page documents the experiment done while trying to sort the issue causing BRAINS to crash when built within Slicer.
Contents
Experiment Setup
Here is the VERY simple program that is failing: https://github.com/BRAINSia/BRAINSTools/blob/SlicerDebugBRAINSFitInstrumentation/BRAINSFit/DebugSlicerProg.cxx
In my slicer build tree: /scratch/johnsonhj/src/Slicer-DEBUG/BRAINSTools (SlicerDebugBRAINSFitInstrumentation)
With git remove –v: origin git://github.com/BRAINSia/BRAINSTools.git (push)
And BRAINSTools hash 31beee592eba2d98655b864e6dc704ac9bf995e8
Experiment results
- BRAINS standalone
- ITKv4 tag:
- ITKv4 options: DCMTK disabled
- Result:
- BRAINS slicer
- ITKv4 tag:
- ITKv4 options: DCMTK disabled, EMsegment disabled
- Result:
===========
[FAILED] Build Slicer: Run Slicers version of Debug johnsonhj@neuron$ /scratch/johnsonhj/src/Slicer-DEBUG/Slicer-build/bin/DebugSlicerProg TESTING: STARTED PRE : 9945 Segmentation fault: 11
===========
[PASSED]
Build Stand Alone version of BRAINSTools using the same source code:
johnsonhj@neuron$ /scratch/johnsonhj/src/Slicer-DEBUG/BT_DEBUG/bin/DebugSlicerProg TESTING: STARTED PRE : 9945 0 POST: 9945 9945 PRE : 9945 0 POST: 9945 9945 TESTING: STOPPED
============================
I have a separate build of Slicer available under a branch named "InstrumentForBRAINSFitFailures" at git@github.com:hjmjohnson/Slicer.git ( a version built on top of today's SlicerSVN)
This branch includes a version of BRAINSTools with a very small program that demonstrates the problem we are seeing in BRAINSFit.
I still think there is something that is overwriting the vtable of this object, and that is the root cause of our problems, but I don't know how to continue debugging that guess.
This is mostly for my own note taking:
There are the experiments that I have done to try to figure out what the heck is going on:
"StandAlone Shared library build of BRAINSTools" BSA_BASE=/scratch/johnsonhj/src/BT_FAILURED_SHARED/BT-DEBUG-SHARED/
"Slicer build of BRAINSTools" SLICER_BASE=/Volumes/scratch/johnsonhj/src/Slicer-DEBUG
TEST #1: [PASS]
===============
BIN=${BSA_BASE}/bin/BRAINSFit DYLD_LIBRARY_PATH=${BSA_BASE}/ITKv4-install/lib
TEST #2: [PASS]
===============
BIN=${SLICER_BASE}/Slicer-build/lib/Slicer-4.2/cli-modules/BRAINSFit DYLD_LIBRARY_PATH=${BSA_BASE}/ITKv4-install/lib
TEST #3: [FAIL]
===============
BIN=${BSA_BASE}/bin/BRAINSFit DYLD_LIBRARY_PATH=${SLICER_BASE}/ITKv4-build/lib
TEST #4: [FAIL]
===============
BIN=${SLICER_BASE}/Slicer-build/lib/Slicer-4.2/cli-modules/BRAINSFit DYLD_LIBRARY_PATH=${SLICER_BASE}/ITKv4-build/lib
TEST #5: [FAIL]
====================
Build with DICOM support turned off. BIN=${SLICER_BASE}/Slicer-build/lib/Slicer-4.2/cli-modules/BRAINSFit DYLD_LIBRARY_PATH=${SLICER_BASE}/ITKv4-build/lib
TEST #6: [FAIL]
====================
Build minimum CLI based program to replicate the problem.
When debugging TEST #6 I put a break point at: /Volumes/scratch/johnsonhj/src/Slicer-DEBUG/BRAINSTools/BRAINSFit/DebugSlicerCLI.cxx line 59 59├> std::cout << "PRE : " << LBFGSBoptimizer->GetUpperBound().size() << " " << upperBound.size() << std::endl;
When stepping into the line, it reports segfault at line 209 of /Volumes/scratch/johnsonhj/src/Slicer-DEBUG/ITKv4/Modules/Numerics/Optimizers/src/itkLBFGSBOptimizer.cxx
204│ void
205│ LBFGSBOptimizer
206│ ::SetUpperBound(
207│ const BoundValueType & value)
208│ {
209├> m_UpperBound = value;
210│ if ( m_OptimizerInitialized )
211│ {
212│ m_VnlOptimizer->set_upper_bound(m_UpperBound);
213│ }
214│
215│ this->Modified();
216│ }
NOTE: NOTE: NOTE: Line 59 of DebugSlicerCLI.cxx DOES NOT CALL "SetUpperBound" it calls "GetUpperBound", and that is the same type of problem we are seeing in BRAINSFit.