D3D11CreateDeviceAndSwapChain throws with unknown cause - c++

for the last weeks i've been running in a strange behaviour of Visual Studio and the game I develop.
After creating the application window with WIN32 CreateWindowExA I initialize DX3D11 with D3D11CreateDeviceAndSwapChain (see line 304 in codefile here).
In VisualStudio executing this line will always result in a crash with the following text in the debug output:
First-chance exception at 0x7713C42D in SpaceLegends.exe: Microsoft C++ exception: _com_error at memory location 0x0032D7A0.
First-chance exception at 0x7713C42D in SpaceLegends.exe: Microsoft C++ exception: _com_error at memory location 0x0032D90C.
First-chance exception at 0x7713C42D in SpaceLegends.exe: Microsoft C++ exception: _com_error at memory location 0x0032D940.
First-chance exception at 0x7713C42D in SpaceLegends.exe: Microsoft C++ exception: _com_error at memory location 0x0032DA58.
First-chance exception at 0x7713C42D in SpaceLegends.exe: Microsoft C++ exception: _com_error at memory location 0x0032E248.
First-chance exception at 0x77B070B4 (ntdll.dll) in SpaceLegends.exe: 0xC0000005: Access violation reading location 0x00000000.
Critical error detected c0000374
SpaceLegends.exe has triggered a breakpoint.
But when I run the exe without VS just as a normal user I don't have any problems to start the application. Also there is no log entry reporting any difficulties or errors!
Due to some reasons I don't get the try-catch around the specific code line does not fire in VS debugging, so there is no exception message I could tell.in
I can't imagine what's wrong with this, neither I have any further idea how to solve or even trace this issue.
EDIT 1:
A full stacktrace from the moment where the exception occurs:
ntdll.dll!_RtlpBreakPointHeap#4() Unknown
ntdll.dll!_RtlpCoalesceFreeBlocks#16() Unknown
ntdll.dll!#RtlpFreeHeap#16() Unknown
ntdll.dll!_RtlFreeHeap#12() Unknown
ntdll.dll!_RtlDebugFreeHeap#12() Unknown
ntdll.dll!#RtlpFreeHeap#16() Unknown
ntdll.dll!_RtlFreeHeap#12() Unknown
ntdll.dll!_LdrpFinalizeAndDeallocateDataTableEntry#4() Unknown
ntdll.dll!_LdrpUnloadDll#8() Unknown
ntdll.dll!_LdrUnloadDll#4() Unknown
guard32.dll!003d6f12() Unknown
[Frames below may be incorrect and/or missing,
no symbols loaded for guard32.dll]
nvumdshim.dll!5dae52c4() Unknown
nvumdshim.dll!5dad777f() Unknown
[External Code]

Related

EVP_aes_256_gcm() fails

when I use EVP_aes_128_cbc() in my code it works fine.
But when use EVP_aes_128_gcm() or EVP_aes_256_gcm() gtest throws error message "unknown file: error: SEH exception with code 0xc0000005 thrown in the test body."
Can anyone help here?

How to get stack trace error exception in C++?

I'm getting following error with one of the third party library in which i have no access to the code. This error is intermittently being thrown and i have no idea what caused the error since i can't view the code. The library is in .SO extension which running in Linux and the library is compiled with C++ version 11 and i have exception catch routine in my function with e.what().
An invalid memory reference (segmentation violation) has occurred.
Is there anyway i can view the stack trace for that error when it is being thrown? Also, any suggestion or advise on what is that error about?

MatLab C++ Shared Dll Library Initialization Crash

I am using Matlab 2013a and Visual Studio 2013. I am trying to use MatLab compiled dll from a C++ console application. My simple Matlab test dll and console application is compiled for 64bit machines (I made sure they are 64bit via dumpbin). I also have correct version of MCR installed on my machine (even if it's not necessary).
I setup my compiler using "mbuild -setup" command.
I compile my .m file using this command line: "mcc -v -W cpplib:mylib -T link:lib myFunc" successfully.
In my console application, I include these libraries: mylib.lib, mclmcrrt.lib, mclmcr.lib, libmx.lib, libmat.lib and use the libraries in this path "C:\Program Files\MATLAB\R2013a\extern\lib\win64\microsoft"
When I debug my program, it successfully initializes MCR using this call: "mclInitializeApplication(NULL, 0)" but when I call "mylibInitialize()" in order to initialize my library, program crashes. It doesn't even throw an axception therefore I cannot handle it using try/catch block. It gives unhandled exception and access vialoation error message.
These are sample debug output messages I got;
First-chance exception at 0x00007FFA22761F08 in MatlabTest.exe: Microsoft C++ exception: xercesc_2_7::NoSuchElementException at memory location 0x000000E263EF4E48.
First-chance exception at 0x00007FFA22761F08 in MatlabTest.exe: Microsoft C++ exception: xsd_binder::MalformedDocumentError at memory location 0x000000E263EF4E40.
First-chance exception at 0x00007FFA22761F08 in MatlabTest.exe: Microsoft C++ exception: xercesc_2_7::NoSuchElementException at memory location 0x000000E263EF4E48.
First-chance exception at 0x00007FFA22761F08 in MatlabTest.exe: Microsoft C++ exception: boost::thread_interrupted at memory location 0x000000E2643FF630.
First-chance exception at 0x00007FFA22761F08 in MatlabTest.exe: Microsoft C++ exception: boost::thread_interrupted at memory location 0x000000E2642FFCD0.
First-chance exception at 0x00007FFA22761F08 in MatlabTest.exe: Microsoft C++ exception: CryptoPP::AES_PHM_Decryption::InvalidCiphertextOrKey at memory location 0x000000E264EFB0F0.
First-chance exception at 0x00007FFA22761F08 in MatlabTest.exe: Microsoft C++ exception: tfFailedException at memory location 0x000000E264EF4C10.
First-chance exception at 0x00007FFA22761F08 in MatlabTest.exe: Microsoft C++ exception: varflowFailedException at memory location 0x000000E264EF9410. The thread 0x3550 has exited with code 0 (0x0). 'MatlabTest.exe' (Win32): Loaded 'C:\Program Files\MATLAB\R2013a\bin\win64\hgbuiltins.dll'. Cannot find or open the PDB file.
First-chance exception at 0x0000000000B46E60 (m_interpreter.dll) in MatlabTest.exe: 0xC0000005: Access violation reading location 0x0000000064EF3B90. Unhandled exception at 0x0000000000B46E60 (m_interpreter.dll) in MatlabTest.exe: 0xC0000005: Access violation reading location 0x0000000064EF3B90.
The program '[12952] MatlabTest.exe' has exited with code 0 (0x0).
I installed MCR to another machine and tried to run this console application. I got the same result.
I tried Loren's Vigenere example too,
http://blogs.mathworks.com/loren/2011/02/03/creating-c-shared-libraries-and-dlls/#respond
It didn't work either.
Do you have any idea why this is happening?
Thanks
It seems problem is MATLAB and Visual Studio version mismatch. If I use MatLab 2016a with Visual Studio 2013, there is no problem and everything works perfectly.
I had the similar problem with Matlab2017 + VS 2015.
Probably there is some conflict with java used by MATLAB.
I've fixed it by using
const char *args[] = {"-nojvm"};
const int count = sizeof(args) / sizeof(args[0]);
mclInitializeApplication(args, count))
instead of
mclInitializeApplication(NULL,0)

Panda3D and load_model c++

I am new to panda3d and am trying the hello world.
I have gotten the program to run with just:
PandaFramework framework;
framework.open_framework(argc, argv);
WindowFramework *window = framework.open_window();
framework.main_loop();
framework.close_framework();
return 0;
however, if I add in :
NodePath environt = window->load_model(framework.get_models(), "panda-model");
environt.reparent_to(window->get_render());
environt.set_scale(0.25, 0.25, 0.25);
environt.set_pos(-8, 42, 0);
before the main_loop(), it won't compile. I have the panda-model.egg.pz in every folder of my c++ project but every time my program breaks on :
environt.reparent_to(window->get_render());
The excat message is: Unhandled exception at 0x0152a317 in Irr.exe: 0xC00001A5: An invalid exception handler routine has been detected.
It compiles fine the only wraning being that it can't find the pdb files but that doesn't matter.
Any ideas?
Btw, im using MSVC++ 2010 and panda3d 1.7.2
The only error I can find is : First-chance exception at 0x00bfa317 in Irr.exe: 0xC0000005: Access violation reading location 0x737265db.
Unhandled exception at 0x00bfa317 in Irr.exe: 0xC00001A5: An invalid exception handler routine has been detected.
The program '[8476] Irr.exe: Native' has exited with code 0 (0x0).
which I'm pretty sure is still rather vague. I'm sorry but its all I can find. I'd be happy to describe it more though if necessary.
Microsoft Visual C++ 2010 is not supported by current versions of Panda3D. You will need to use 2008 or compile the Panda3D SDK from source against MSVC 2010. (This is not as straightforward as it sounds, as you will also need to compile some of the thirdparty packages to be compatible with 2010. However, it is possible.)
If you insist on using 2010 instead of 2008, this forum post may be helpful:
https://www.panda3d.org/forums/viewtopic.php?t=12663

Problems with including afxmt.h in VC++ 2010

I'm getting exceptions when I include afxmt.h, I know it's not my code because I tested it with an empty project that only included that file.
It first throws a first-chance exception (mfc100ud.dll) and then it jumps to thrdcore.cpp AfxInitThread() and then goes to tidtable.c
Is there some project settings that I'm missing or some other stuff? I'm using VC++ 2010 Professional.
First-chance exception at 0x00b794ea (mfc100ud.dll) in Quick_Test.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x77b815de in Quick_Test.exe: 0xC0000005: Access violation reading location 0x00000000.
Stops at thrdcore.cpp line 405 and then in tidtable.c line 500.
EDIT:
Just tested this with a project that has precompiled headers and it worked. How would I make it work on my other projects, that were originally empty? Or should I just use a project with precompiled headers?
One reason could be that you are using release and trying to access the debug dll. Debug dlls usually ends with a "d" letter