Cannot lauch 64 bits application under VS2015

1

I migrated an existing C++ application from VS2008 to VS2015, which is made of mixed code.

It worked like a charm both compiled for 32 and 64 bits under VS2008.

Now compiled under VS2015, the 32 bits version works (though it recompiles nearly every time) but the 64 bits version (Release build) crashes immediately with the message

Unhandled exception at 0x00007FFF52E3B049 (ntdll.dll) in mViz+.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FFF52EA27F0)

and call stack

    ntdll.dll!RtlReportFatalFailure()   Unknown
    ntdll.dll!RtlReportCriticalFailure()    Unknown
    ntdll.dll!RtlpHeapHandleError() Unknown
    ntdll.dll!RtlpHpHeapHandleError()   Unknown
    ntdll.dll!RtlpLogHeapFailure()  Unknown
    ntdll.dll!RtlSizeHeap() Unknown
    ucrtbase.dll!_recalloc_base()   Unknown
    ucrtbase.dll!<lambda>(void)()   Unknown
    ucrtbase.dll!__crt_seh_guarded_call<int>::operator()<<lambda_638799b9deba96c50f710eeac98168cd>,<lambda>(void) & __ptr64,<lambda_a6f7d7db0129f75315ebf26d50c089f1> >()   Unknown
    ucrtbase.dll!_register_onexit_function()    Unknown
>   mViz+.exe!_onexit(int(*)() function) Line 268   C++
    mViz+.exe!atexit(void(*)() function) Line 276   C++
    mViz+.exe!__scrt_initialize_thread_safe_statics() Line 110  C++
    [External Code] 
    mscoreei.dll!_CorExeMain()  Unknown
    mscoree.dll!_CorExeMain_Exported()  Unknown
    kernel32.dll!BaseThreadInitThunk()  Unknown
    ntdll.dll!RtlUserThreadStart()  Unknown

This is what happens under debugger control. Otherwise, the application just doesn't start.

A Debug build also has a problematic behavior. Without the debugger,

enter image description here

and with:

Exception thrown at 0x00007FFF52DA70A0 (ntdll.dll) in mViz+.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

If there is a handler for this exception, the program may be safely continued.

This seems to be a heap corruption problem but I have the feeling that the crash occurs before any of my code is called.

How can I investigate that ?


Update:

Under certain circumstances, I get the following message:

Unhandled Exception: System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at _initterm_e((fnptr)* pfbegin, (fnptr)* pfend) in f:\dd\vctools\crt\crtw32\msilcrt\puremsilcode.cpp:line 69
   at <CrtImplementationDetails>.LanguageSupport.InitializeNative(LanguageSupport* ) in f:\dd\vctools\crt\crtw32\msilcrt\mstartup.cpp:line 355
   at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* ) in f:\dd\vctools\crt\crtw32\msilcrt\mstartup.cpp:line 598
   at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) in f:\dd\vctools\crt\crtw32\msilcrt\mstartup.cpp:line 805
   at .cctor() in f:\dd\vctools\crt\crtw32\msilcrt\mstartup.cpp:line 856
   --- End of inner exception stack trace ---

Update 2:

I know that it is difficult to answer without seeing the phenomenon. But I am not asking for a cause, I am rather asking about how to investigate deeper, given that the debugger is of no help. (All it tells me is that there is heap corruption at launch-time.)


Update 3:

When migrated to VS2017, the application does start, but the 64 bits version is dead slow. In fact, unusable. One of the threads shows 100% load for ages. The 32 bits build behaves normally.

c++
visual-studio-2015
crash
migration
asked on Stack Overflow Jul 12, 2019 by Yves Daoust • edited Jul 13, 2019 by Yves Daoust

1 Answer

0

I have made big progress. From this post, Mixed-mode C++/CLI crashing: heap corruption in atexit (static destructor registration), I observe that indeed the entry point of the application was not standard, and restoring it solved the crash issue.

Now remains to understand the slowness of the 64 bits version.

answered on Stack Overflow Jul 13, 2019 by Yves Daoust

User contributions licensed under CC BY-SA 3.0