# Crash on calling ImageFileReader::New() MSVS 2019

**URL:** https://discourse.itk.org/t/crash-on-calling-imagefilereader-new-msvs-2019/3984
**Category:** Beginner Questions
**Tags:** visual-studio, cpp
**Created:** [March 25, 2021, 11:01am UTC](https://discourse.itk.org/t/crash-on-calling-imagefilereader-new-msvs-2019/3984 "2021-03-25T11:01:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ljubak](https://discourse.itk.org/user_avatar/discourse.itk.org/ljubak/32/1989_2.png) [@ljubak](https://discourse.itk.org/u/ljubak)
#### Post date: [March 25, 2021, 11:01am UTC](https://discourse.itk.org/t/crash-on-calling-imagefilereader-new-msvs-2019/3984/1 "2021-03-25T11:01:05Z")

</div>

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](https://discourse.itk.org/uploads/default/original/2X/f/f05769ddc273805119fb2790cc388d334124fab4.png)

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

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 25, 2021, 1:57pm UTC](https://discourse.itk.org/t/crash-on-calling-imagefilereader-new-msvs-2019/3984/2 "2021-03-25T13:57:01Z")

</div>

> [@ljubak](#):
>
> Error #1: WARNING: heap allocation failed

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.

---

<div class="post-metadata">

### Author: ![ljubak](https://discourse.itk.org/user_avatar/discourse.itk.org/ljubak/32/1989_2.png) [@ljubak](https://discourse.itk.org/u/ljubak)
#### Post date: [March 25, 2021, 3:32pm UTC](https://discourse.itk.org/t/crash-on-calling-imagefilereader-new-msvs-2019/3984/3 "2021-03-25T15:32:13Z")

</div>

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