[ITK-dev] Exception in itk::ResampleImageFilter multithreaded part after ITK migration from 3.20.1 to 4.6.1

Simon ESNEAULT simon.esneault at gmail.com
Wed Dec 3 10:19:48 EST 2014


Finally just found the error ...

We had somewhere deep in our code the following lines ...
#ifndef ThreadIdType
#define ThreadIdType int
#endif

Depending on the code tested, that was picked at the first place, thus
messing with the new ITK API !

Sorry for the noise, everything back in order

Thanks for the support

Simon



2014-12-03 15:22 GMT+01:00 Simon ESNEAULT <simon.esneault at gmail.com>:

> Hi Bradley,
>
> Thanks for your answer. You're right it can not be the export otherwise it
> would not link.
> Plus, I can now reproduce the exact same exception at runtime on OSX
> (10.10, XCode 6) with our framework updated and build against ITK 4.6.1
>
> I've search all copies of ResampleFilter and the only one left on the
> computers (Win and OSX) are the one from ITK 4.6.1. It must be something
> else !
>
> Here is what we do with cmake :
>
> set( Itk_INCLUDE_DIR
> ${CMAKE_BINARY_DIR}/../externals/ITK-4.6.1/${OS_NAME}/include )
> set( Itk_LIBRARY_DIR
> ${CMAKE_BINARY_DIR}/../externals/ITK-4.6.1/${OS_NAME}/lib/${CMAKE_BUILD_TYPE}
> )
> set( Itk_LIBRARIES
> ITKBiasCorrection-4.6
> ITKBioCell-4.6
> ITKCommon-4.6
> ITKDICOMParser-4.6
> itkdouble-conversion-4.6
> ITKEXPAT-4.6
> ITKFEM-4.6
> itkgdcmCommon-4.6
> itkgdcmDICT-4.6
> itkgdcmDSED-4.6
> itkgdcmIOD-4.6
> itkgdcmjpeg12-4.6
> itkgdcmjpeg16-4.6
> itkgdcmjpeg8-4.6
> itkgdcmMSFF-4.6
> ITKgiftiio-4.6
> itkhdf5-4.6
> itkhdf5_cpp-4.6
> ITKIOBioRad-4.6
> ITKIOBMP-4.6
> ITKIOCSV-4.6
> ITKIOGDCM-4.6
> ITKIOGE-4.6
> ITKIOGIPL-4.6
> ITKIOHDF5-4.6
> ITKIOImageBase-4.6
> ITKIOIPL-4.6
> ITKIOJPEG-4.6
> ITKIOLSM-4.6
> ITKIOMesh-4.6
> ITKIOMeta-4.6
> ITKIOMRC-4.6
> ITKIONIFTI-4.6
> ITKIONRRD-4.6
> ITKIOPNG-4.6
> ITKIOSiemens-4.6
> ITKIOSpatialObjects-4.6
> ITKIOStimulate-4.6
> ITKIOTIFF-4.6
> ITKIOTransformBase-4.6
> ITKIOTransformHDF5-4.6
> ITKIOTransformInsightLegacy-4.6
> ITKIOTransformMatlab-4.6
> ITKIOVTK-4.6
> ITKIOXML-4.6
> itkjpeg-4.6
> ITKKLMRegionGrowing-4.6
> ITKLabelMap-4.6
> ITKMesh-4.6
> ITKMetaIO-4.6
> itkNetlibSlatec-4.6
> ITKniftiio-4.6
> ITKNrrdIO-4.6
> itkopenjpeg-4.6
> ITKOptimizers-4.6
> ITKOptimizersv4-4.6
> ITKPath-4.6
> itkpng-4.6
> ITKPolynomials-4.6
> ITKQuadEdgeMesh-4.6
> ITKSpatialObjects-4.6
> ITKStatistics-4.6
> itksys-4.6
> itktiff-4.6
> itkv3p_lsqr-4.6
> itkv3p_netlib-4.6
> itkvcl-4.6
> ITKVideoCore-4.6
> ITKVideoIO-4.6
> itkvnl-4.6
> ITKVNLInstantiation-4.6
> itkvnl_algo-4.6
> ITKVTK-4.6
> ITKWatersheds-4.6
> itkzlib-4.6
> ITKznz-4.6
> )
>
> And later on,
> include_directories( ${Itk_INCLUDE_DIR} )
> link_directories( ${Itk_LIBRARY_DIR} )
> target_link_libraries( my_exec ${Itk_LIBRARIES} )
> or target_link_libraries( my_lib ${Itk_LIBRARIES} )
>
> After that we Register Itk factories as stated in the first mail.
> Is this sufficient?
> Can this be responsible of such a behavior ?
>
> Simon
>
>
> 2014-12-02 15:45 GMT+01:00 Bradley Lowekamp <blowekamp at mail.nih.gov>:
>
>> Hello Simon,
>>
>> If you don't have your exports correct it'd likely result in a link error.
>>
>> Given the error message you report, it sounds like you are using an old
>> version of the ResampleFilter. I'd look into seeing if there are old copies
>> of ITK 3.20 laying around that may be included in your project. You can not
>> use mix symbols and includes from different version of ITK.
>>
>> Brad
>>
>> On Dec 2, 2014, at 4:51 AM, Simon ESNEAULT <simon.esneault at gmail.com>
>> wrote:
>>
>> Hi Bill,
>>
>> Thanks for your reply. I have downloaded and executed succesfully the
>> Upsampling example (
>> http://itk.org/Wiki/ITK/Examples/ImageProcessing/Upsampling), using the
>> version of ITK (4.6.1) we used in the framework.
>>
>> It appears our problem is probably related with our framework
>> architecture, and some dll import/export on windows. We wrapped all our ITK
>> code in a library WrapItk.dll. And there are some others libraries, all of
>> them can make use of native ITK code or wrapped ITK code. This used to work
>> fine with ITK 3.20.1, but it's seems broken in 4.6.1.
>>
>> Not only the Resample filter raise an exception but all the MultiThreaded
>> filter in ITK. When debugging, we go through
>> itk::ResampleImageFilter::BeforeThreadedGenerateData() just fine, and
>> somehow, when ThreadedGenerateData() is called we fall back in the mother
>> class ImageSource method, hence raising the exception.
>>
>> Anyone know how to use properly ITK code with multiple DLL's on windows ?
>> ie having an image loaded with ITK code from one DLL, and some ITK filter
>> executed in another DLL without trouble ?
>> We use that sort of mechanism to export functions properly between DLLs.
>> #if SOME_DLL_DEFINITIONS
>> #define MY_EXPORT __declspec(dllexport)
>> #else
>> #define MY_EXPORT __declspec(dllimport)
>>
>> I will try to sum things up in scheme  if that can help ...
>>
>> Thanks
>> Simon
>>
>>
>> 2014-12-01 14:51 GMT+01:00 Bill Lorensen <bill.lorensen at gmail.com>:
>>
>>> Very strange.
>>>
>>> Could you try building and running this example:
>>> http://itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter
>>>
>>> Bill
>>>
>>> On Mon, Dec 1, 2014 at 7:53 AM, Simon ESNEAULT <simon.esneault at gmail.com>
>>> wrote:
>>> > Hello ITK community
>>> >
>>> > After the migration from ITK 3.20.1 to ITK 4.6.1, I'm getting a runtime
>>> > exception when using itk::ResampleImageFilter in our framework. The
>>> output
>>> > looks like this :
>>> >
>>> > Problem during Resample filtering:
>>> >
>>> D:\Dev\DevCpp-Qt5\cmake-externals\ITK\src\Modules\Core\Common\src\itkMultiThreader.cxx:358:
>>> > itk::ERROR: MultiThreader(31CAAD18): Exception occurred during
>>> > SingleMethodExecute
>>> >
>>> c:\dev\Dev_qt5\externals\itk-4.6.1\win32\include\itkImageSource.hxx:267:
>>> > itk::ERROR: ResampleImageFilter(31AC2E90): Subclass should override
>>> this
>>> > method!!!
>>> > The signature of ThreadedGenerateData() has been changed in ITK v4 to
>>> use
>>> > the new ThreadIdType.
>>> > ResampleImageFilter::ThreadedGenerateData() might need to be updated
>>> to used
>>> > it.
>>> >
>>> > That is weird, because the itkResampleImageFilter is the one delivered
>>> with
>>> > ITK 4.6.1, so it must have followed the API changed ...
>>> >
>>> > The context is :
>>> > Visual Studio 2013 community, 32 bit build, ITK build in shared library
>>> > mode. That's quite a big project, with VTK, Qt, OpenCV, DCMTK, zlib ...
>>> > I'm not using cmake in the usual way (ie no find_package(ITK)
>>> > include(${ITK_USE_FILE}) ) but we list the libraries and includes. I
>>> know
>>> > there are some factories to register in that case, we're doing this in
>>> the
>>> > main.cpp :
>>> > itk::TransformFactoryBase::RegisterDefaultTransforms();
>>> > itk::PNGImageIOFactory::RegisterOneFactory();
>>> > itk::MetaImageIOFactory::RegisterOneFactory();
>>> > itk::NrrdImageIOFactory::RegisterOneFactory();
>>> >
>>> > Am I missing some others factories to register in order to run
>>> properly the
>>> > resampleImageFilter ?
>>> > Anyone else had a similar runtime exception with a native ITK filte,
>>> or know
>>> > what would raise such an exception ?
>>> >
>>> > Thanks
>>> >
>>> > --
>>> > ------------------------------------------------------------------
>>> > Simon Esneault
>>> > ------------------------------------------------------------------
>>> >
>>> > _______________________________________________
>>> > 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://kitware.com/products/protraining.php
>>> >
>>> > 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://public.kitware.com/mailman/listinfo/insight-developers
>>> >
>>>
>>>
>>>
>>> --
>>> Unpaid intern in BillsBasement at noware dot com
>>>
>>
>>
>>
>> --
>> ------------------------------------------------------------------
>> Simon Esneault
>> ------------------------------------------------------------------
>>  _______________________________________________
>> 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://kitware.com/products/protraining.php
>>
>> 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://public.kitware.com/mailman/listinfo/insight-developers
>>
>>
>>
>
>
> --
> ------------------------------------------------------------------
> Simon Esneault
> ------------------------------------------------------------------
>



-- 
------------------------------------------------------------------
Simon Esneault
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20141203/7d990e83/attachment.html>


More information about the Insight-developers mailing list