Visual Studio 2019 - heap corruption

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?


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:

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