Crash on calling ImageFileReader::New() MSVS 2019

Hello everyone!

I have recently compiled ITK on Windows 7 using Community MSVS 2019. Now I am trying to get myself acquainted with ITK and I am trying out to compile the first examples. And immediately I run into a problem trying to run ImageReadWrite.cxx example from the IO directory. The application compiles without trouble but when I run it crashes on line:

129: ReaderType::Pointer reader = ReaderType::New();

with the message:
Crash Error

When I run it through drmemory it gives the following report:

Dr. Memory version 2.3.0 build 1 built on Feb 6 2020 06:07:09
Windows version: WinVer=61;Rel=;Build=7601;Edition=Professional
Dr. Memory results for pid 12296: “itk_tiff_test.exe”
Application cmdline: “itk_tiff_test.exe …\libtiff_test\data\QA20200727016.tif .\test.png”
Recorded 118 suppression(s) from default C:\Program Files (x86)\Dr. Memory\bin64\suppress-default.txt

Error #1: WARNING: heap allocation failed
# 0 replace_malloc [d:\drmemory_package\common\alloc_replace.c:2577]
# 1 ITKCommon-5.2.dll!itk::DynamicLoader::OpenLibrary +0xa5f2 (0x000007fec625c283 <ITKCommon-5.2.dll+0x5c283>)
# 2 ITKCommon-5.2.dll!? +0x0 (0x000007fec620276b <ITKCommon-5.2.dll+0x276b>)
# 3 ITKCommon-5.2.dll!itk::ImageIORegion::operator= +0x207 (0x000007fec621ea08 <ITKCommon-5.2.dll+0x1ea08>)
# 4 ITKCommon-5.2.dll!itk::ProcessObject::SetInput +0x6d (0x000007fec6222c6e <ITKCommon-5.2.dll+0x22c6e>)
# 5 itk::ImageFileReader<>::SetFileNameInput [C:\ITK\src\ITK\Modules\IO\ImageBase\include\itkImageFileReader.h:104]
# 6 itk::ImageFileReader<>::ImageFileReader<> [C:\ITK\src\ITK\Modules\IO\ImageBase\include\itkImageFileReader.hxx:39]
# 7 itk::ImageFileReader<>::New [C:\ITK\src\ITK\Modules\IO\ImageBase\include\itkImageFileReader.h:86]
# 8 main [C:\Users\Physicist\Documents\Projects\work_in_progress\cpp_projects\work_in_progress\itk_tiff_test\main.cpp:129]
Note: @0:00:11.760 in thread 8176

Error #2: LEAK 216 direct bytes 0x0000000002f70a40-0x0000000002f70b18 + 676 indirect bytes
# 0 replace_RtlAllocateHeap [d:\drmemory_package\common\alloc_replace.c:3771]
# 1 ntdll.dll!RtlGetOwnerSecurityDescriptor +0x255 (0x0000000077aa8f96 <ntdll.dll+0x8f96>)
# 2 ntdll.dll!RtlGetOwnerSecurityDescriptor +0x14c (0x0000000077aa8e8d <ntdll.dll+0x8e8d>)
# 3 ntdll.dll!RtlUserThreadStart +0x9e (0x0000000077acc59f <ntdll.dll+0x2c59f>)

Error #3: LEAK 200 direct bytes 0x0000000002f743d0-0x0000000002f74498 + 0 indirect bytes
# 0 replace_RtlAllocateHeap [d:\drmemory_package\common\alloc_replace.c:3771]
# 1 aswhook.dll!? +0x0 (0x000007fee644383c <aswhook.dll+0x383c>)
# 2 aswhook.dll!? +0x0 (0x000007fee644532f <aswhook.dll+0x532f>)
# 3 ntdll.dll!RtlUserThreadStart +0x26b (0x0000000077acc76c <ntdll.dll+0x2c76c>)

Error #4: POSSIBLE LEAK 143 direct bytes 0x0000000002f7a010-0x0000000002f7a09f + 229 indirect bytes
# 0 replace_malloc [d:\drmemory_package\common\alloc_replace.c:2577]
# 1 VCRUNTIME140D.dll!_std_type_info_name +0x165 (0x000007fec7c18036 <VCRUNTIME140D.dll+0x8036>)
# 2 type_info::name [C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime_typeinfo.h:97]
# 3 itk::ObjectFactory<>::Create [C:\ITK\src\ITK\Modules\Core\Common\include\itkObjectFactory.h:61]
# 4 itk::SimpleDataObjectDecorator<>::New [C:\ITK\src\ITK\Modules\Core\Common\include\itkSimpleDataObjectDecorator.h:81]
# 5 itk::ImageFileReader<>::SetFileName [C:\ITK\src\ITK\Modules\IO\ImageBase\include\itkImageFileReader.h:104]
# 6 itk::ImageFileReader<>::ImageFileReader<> [C:\ITK\src\ITK\Modules\IO\ImageBase\include\itkImageFileReader.hxx:39]
# 7 itk::ImageFileReader<>::New [C:\ITK\src\ITK\Modules\IO\ImageBase\include\itkImageFileReader.h:86]
# 8 main [C:\Users\Physicist\Documents\Projects\work_in_progress\cpp_projects\work_in_progress\itk_tiff_test\main.cpp:129]

Reached maximum leak report limit (-report_leak_max). No further leaks will be reported.

===========================================================================
FINAL SUMMARY:

DUPLICATE ERROR COUNTS:
Error # 2: 8
Error # 3: 8

SUPPRESSIONS USED:

ERRORS FOUND:
0 unique, 0 total unaddressable access(es)
0 unique, 0 total uninitialized access(es)
0 unique, 0 total invalid heap argument(s)
0 unique, 0 total GDI usage error(s)
0 unique, 0 total handle leak(s)
1 unique, 1 total warning(s)
2 unique, 16 total, 8736 byte(s) of leak(s)
1 unique, 1 total, 372 byte(s) of possible leak(s)
ERRORS IGNORED:
5 potential error(s) (suspected false positives)
(details: C:\Users\Physicist\AppData\Roaming\Dr. Memory\DrMemory-itk_tiff_test.exe.12296.000\potential_errors.txt)
1 potential leak(s) (suspected false positives)
(details: C:\Users\Physicist\AppData\Roaming\Dr. Memory\DrMemory-itk_tiff_test.exe.12296.000\potential_errors.txt)
43 unique, 92 total, 44648 byte(s) of still-reachable allocation(s)
(re-run with “-show_reachable” for details)
23087 leak(s) beyond -report_leak_max
Details: C:\Users\Physicist\AppData\Roaming\Dr. Memory\DrMemory-itk_tiff_test.exe.12296.000\results.txt

Is your image too big to fit into your memory? If it fits, then your leak detector library interferes with ITK’s smart pointer memory management. Try compiling without it.

No. In that stage of execution code only initialize the pointer. Will try to compile it without smart pointer memory management.