Crash with ActiveQt and Visual Studio
-
I'm primarily a opensource Linux developer and don't have much experience with Visual Studio.
But I have written a program in C++/Qt that I've integrated with some functionality in a program written in Visual Basic 6.
So I use ActiveQt to call up the Visual Basic functions, this works great when I compile the program with MinGW in 32 bit on Windows, I can even cross-compile the program from Linux and it still works.
However, when I compile with Visual Studio It crashes on certain functions. The common thing seem to be that the VB6 function I call uses a GUI, because it works for all functions I have tested that does not show a GUI. However it does not crash when I run the VB6 library in debug while I call the function in my C++ program from Visual Studio.I use dumpcpp on the VB6 library, then I call the function. But I've also tried using dynamicCall().
It crashes in
qt_metacall(QMetaObject::InvokeMetaMethod, 8, _a);
in the following code that is exported from the VB6 library:inline bool uOppdat::DoUpdate() { bool qax_result; void *_a[] = {(void*)&qax_result}; qt_metacall(QMetaObject::InvokeMetaMethod, 8, _a); return qax_result; }
The crash is just a standard access violation, code 0xC0000005.
For Visual Studio I use Qt 5.15.2 from the installer. I don't have a commercial license as this is something I'm doing on my spare time, but I'm trying to get the company I work for to start using Qt and purchase a license, this could be a deal breaker so I appreciate any help.
With MinGW I also used the Qt 5.15.2 from the installer in addition to my own cross compiled Qt, both works flawlessly without any crashes calling the exact same VB6 functions with GUI.
-
Hi, perhaps the crashes occur due to different calling conventions: stdcall and cdecl
Maybe in your case MinGW is lucky and chooses the right flavor and Visual Studio gets it wrong. And the reason for no crashes in debug mode could be because then you have some extra padding on the stack which avoids the crashes.
It should be possible to add some compiler switch to Visual Studio to select the other calling convention.
Note: this is just a guess :-) -
I'm using CMake.
If I add /Gz to add_compile_options. it fails to link when compiling.
When adding /Gd, it's the same behavior as before.
I did a full rebuild.