Troubleshooting a crash during run time initialization in mixed native/.NET application

0

I have an existing c++/.net 4.0 imaging application with a Windows Forms GUI that uses an unmanaged NI camera link library (IMAQ). I would like to switch to a USB camera and so much use their IMAQdx library.

However, when I try to include "nivision.h" (even without adding any other code), which includes types for the IMAQdx library, the application crashes during initialization with:

Exception thrown at 0x00007FFEE29CFD70 (ntdll.dll) in NLSM Rochester.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

and prior to reaching main():

    ntdll.dll!RtlValidateHeap() Unknown
    KernelBase.dll!HeapValidate()   Unknown
    ucrtbased.dll!_CrtIsValidHeapPointer(const void * block) Line 1407  C++
    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) &,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 975   C++
    ucrtbased.dll!_register_onexit_function(_onexit_table_t * table, int(*)() function) Line 149    C++
    imageProgram.exe!_onexit(int(*)() function) Line 268    C++
    imageProgram.exe!atexit(void(*)() function) Line 276    C++
    imageProgram.exe!std::basic_streambuf<char,struct std::char_traits<char> >::xsputn(char const *,__int64)    C++
    imageProgram.exe!`anonymous namespace'::`dynamic initializer for 'std::_Fac_tidy_reg::A0x627c3ff0(void)''(void) C++
    [Managed to Native Transition]  
    imageProgram.exe!_initterm(void (__cdecl*)()* pfbegin, void (__cdecl*)()* pfend) Line 127   C++
    imageProgram.exe!<CrtImplementationDetails>::LanguageSupport::InitializeNative() Line 361   C++
    imageProgram.exe!<CrtImplementationDetails>::LanguageSupport::_Initialize() Line 598    C++
    imageProgram.exe!<CrtImplementationDetails>::LanguageSupport::Initialize() Line 805 C++
    imageProgram.exe!.cctor() Line 856  C++
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    [Native to Managed Transition]  
    mscoreei.dll!_CorExeMain()  Unknown
    mscoree.dll!_CorExeMain_Exported()  Unknown
    kernel32.dll!BaseThreadInitThunk()  Unknown
    ntdll.dll!RtlUserThreadStart()  Unknown

The included NI example code, which is also VS2015 c++ w/ CLR support works perfectly, so I am pretty sure the underlying libraries are installed correctly and the problem is how I have configured my application.

From the stack trace it looks like something goes wrong during initialization of the c runtime, but I'm at a loss for how to debug this or why this one specific c library has trouble when others do not.

Edit: Updated the stack trace after loading all symbols from Microsoft. This gives the exception in RtlValidateHeap

.net
visual-c++
asked on Stack Overflow Sep 9, 2019 by user1850479 • edited Sep 10, 2019 by user1850479

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0