I am developing a Windows Forms application under Visual Studio 2015. It was migrated from code running under VS2008.
When I try to launch the Debug version of the application, I get the message box below, before anything appears. I have also copied the call stack.
None of my code is called, the crash occurs before, during application initialization. It seems to be a heap corruption.
I have tried many things, such as reinstalling VS with different options, changing the Target Platform Version, switching between 32 and 64 bits. Nothing worked.
Is this a known issue ? How can I address this ?
I somewhat suspect a problem with ucrtbased.dll, as I found several posts about installation problems of this dll with VS2015.
ucrtbased.dll!_msize_dbg(void * block, int block_use) Line 1059 C++
ucrtbased.dll!_recalloc_dbg(void * block, unsigned __int64 count, unsigned __int64 element_size, int block_use, const char * file_name, int line_number) Line 784 C++
ucrtbased.dll!_register_onexit_function::__l2::<lambda>() Line 112 C++
ucrtbased.dll!__crt_seh_guarded_call<int>::operator()<void <lambda>(void),int <lambda>(void) & __ptr64,void <lambda>(void) >(__acrt_lock_and_call::__l2::void <lambda>(void) && setup, _register_onexit_function::__l2::int <lambda>(void) & action, __acrt_lock_and_call::__l2::void <lambda>(void) && cleanup) Line 204 C++
ucrtbased.dll!__acrt_lock_and_call<int <lambda>(void) >(const __acrt_lock_id lock_id, _register_onexit_function::__l2::int <lambda>(void) && action) Line 961 C++
ucrtbased.dll!_register_onexit_function(_onexit_table_t * table, int(*)() function) Line 149 C++
mViz Comparator.exe!_onexit(int(*)() function) Line 268 C++
mViz Comparator.exe!atexit(void(*)() function) Line 276 C++
mViz Comparator.exe!__scrt_initialize_thread_safe_statics() Line 109 C++
00007ff889c217db() Unknown
00007ff889c2170f() Unknown
00007ff889c214be() Unknown
00007ff889c2105e() Unknown
00007ff889c20dc3() Unknown
00007ff889c209c3() Unknown
clr.dll!CallDescrWorkerInternal() Unknown
clr.dll!CallDescrWorkerWithHandler() Unknown
clr.dll!DispatchCallDebuggerWrapper(struct CallDescrData *,class ContextTransitionFrame *,int) Unknown
clr.dll!DispatchCallSimple() Unknown
clr.dll!MethodTable::RunClassInitEx() Unknown
clr.dll!MethodTable::DoRunClassInitThrowing() Unknown
clr.dll!MethodTable::CheckRunClassInitThrowing() Unknown
clr.dll!DomainFile::Activate() Unknown
clr.dll!DomainFile::DoIncrementalLoad() Unknown
clr.dll!AppDomain::TryIncrementalLoad() Unknown
clr.dll!AppDomain::LoadDomainFile() Unknown
clr.dll!AppDomain::LoadDomainAssemblyInternal() Unknown
clr.dll!AppDomain::LoadDomainAssembly() Unknown
clr.dll!AppDomain::LoadAssembly(class AssemblySpec *,class PEAssembly *,enum FileLoadLevel,struct AssemblyLoadSecurity *) Unknown
clr.dll!SystemDomain::ExecuteMainMethod() Unknown
clr.dll!ExecuteEXE(struct HINSTANCE__ *) Unknown
clr.dll!_CorExeMainInternal() Unknown
clr.dll!_CorExeMain() Unknown
mscoreei.dll!_CorExeMain() Unknown
mscoree.dll!_CorExeMain_Exported() Unknown
kernel32.dll!BaseThreadInitThunk() Unknown
> ntdll.dll!RtlUserThreadStart() Unknown
Update:
The problem persist with other similar applications and also 32/64 Release/Debug builds.
But I have now observed that the problem is due to a global instance of a class defined in a separate unmanaged library. Note that this code has been working for ages with many Visual Studio versions. Also note that the crash occurs before the constructor is called.