# Visual Studio 2019 - heap corruption

**URL:** <https://root-forum.cern.ch/t/visual-studio-2019-heap-corruption/48506>\
**Category:** Newbie\
**Created:** [January 23, 2022, 2:21am UTC](https://root-forum.cern.ch/t/visual-studio-2019-heap-corruption/48506 "2022-01-23T02:21:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdattalo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sdattalo](https://root-forum.cern.ch/u/sdattalo)\
**Post date:** [January 23, 2022, 2:21am UTC](https://root-forum.cern.ch/t/visual-studio-2019-heap-corruption/48506/1 "2022-01-23T02:21:53Z")

</div>

root version: root\_v6.24.06 Debug  
Visual Studio 2019 - Win32 Debug  
Windows 10

I have a simple ‘helloworld’ root app that I’ve been able to successfully build with Visual Studio 2019. The include file paths, library paths and references to the root DLLs have all been resolved. However, when I invoke the built executable from within the Visual Studio 2019 IDE, the program crashes with a heap error. There appears to be an issue with simply including TH1.h. I simplified the application to the bare essence to illustrate the issue:

#include “TH1.h”

int main(int argc, char\*\* argv)  
{  
return 0;  
}

This compiles just fine for me, but it crashes when I run it. Specifically it reports:

Unhandled exception at 0x77D46C43 (ntdll.dll) in CernRoot.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77D83960).

I believe Root is installed correctly since I can run the various tutorials just fine.

Any suggestions?

Thanks,  
Scott

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 24, 2022, 7:14am UTC](https://root-forum.cern.ch/t/visual-studio-2019-heap-corruption/48506/2 "2022-01-24T07:14:08Z")

</div>

This might be due to wrong/incompatible compiler flags. How do you compile your code? I.e I have no problem when compiling and running your code on the `x86 Native Tools Command Prompt for VS 2019`:

```auto
C:\Users\bellenot\rootdev>cl -nologo -Zc:__cplusplus -std:c++17 -MD -GR -EHsc- -W3 -D_WIN32 -O2 main.cxx -I%ROOTSYS%\include /link -debug -LIBPATH:%ROOTSYS%\lib libCore.lib libHist.lib
main.cxx

C:\Users\bellenot\rootdev>main

C:\Users\bellenot\rootdev>

```
