Skip to content

Commit c3b6a52

Browse files
authored
BUG: Fixed an issue with ITK tiff reading on Windows conda builds (#1475)
Fixed an issue with ITK tiff reading on windows with a workaround * ITK misconfigures ITKIOTIFF on Windows when using an external libtiff such that certain files may trigger a nullptr access. We work around this by turning off the global warning display because the nullptr access occurs in an itkWarningMacro. Signed-off-by: Jared Duffey <jared.duffey@bluequartz.net>
1 parent 5d22556 commit c3b6a52

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/Plugins/ITKImageProcessing/src/ITKImageProcessing/ITKImageProcessingPlugin.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ ITKImageProcessingPlugin::ITKImageProcessingPlugin()
3939
if(!s_IsRegistered)
4040
{
4141
RegisterITKImageIO();
42+
43+
/*
44+
2025-12-02
45+
Tested with ITK 5.4.5 and libtiff 4.7.1
46+
Primarily affects DREAM3DNX built for conda distribution
47+
When ITKIOTIFF is built with an external libtiff, it misconfigures on Windows. It checks for the existence of TIFFFieldReadCount using CMake's check_type_size().
48+
check_type_size() uses try_compile() which uses sizeof(). It is against the standard to do `sizeof(func)`. The correct way is to do `sizeof(&func)`. gcc and clang
49+
allow the first version without -pedantic but msvc rejects it. This leads to a situation where ITK_TIFF_HAS_TIFFFieldReadCount is not defined but
50+
ITK_TIFF_HAS_TIFFField is. Then in itkTIFFImageIO.cxx, different code is selected to access the field name. For certain files, this can come back as nullptr.
51+
For the particular file we tested with, the field data type (7) was unsupported by ITK. Then we end up at the default case of a switch where ITK attempts to print
52+
out the field name and data type to say that it isn't supported. But since the field name is nullptr it crashes.
53+
ITK 6 looks to avoid this issue by increasing the minimum required libtiff version removing the need for workarounds.
54+
55+
Here we disable the global warning display on Windows which prevents the nullptr from being accessed. This prevents *all* warnings from being printed,
56+
but simplnx will primarily be used with DREAM3DNX which, as a GUI application on Windows, doesn't have a terminal by default to print to anyways.
57+
Once ITK fixes this issue, this code can be removed.
58+
*/
59+
#ifdef _WIN32
60+
itk::Object::GlobalWarningDisplayOff();
61+
#endif
62+
4263
s_IsRegistered = true;
4364
}
4465
}

0 commit comments

Comments
 (0)