1

I want to integrate QT into an existing desktop C++ project. The requirements were that QT should be statically built with MSVC2013 64bit and with /MT flag set for compiler, so I built QT5.5.0 from sources.

The integration worked as expected, I managed to test some of Qt's object(QFile, QObject) from QtCore.lib. The application seems to run without any problems, without crashing. However, the program exists with -1073741819 error level. I attached the debugger and tried to catch the exception in Visual Studio and I got the following:

First-chance exception at 0x00007FFAC6E4E1A2 in silversim.exe: 0xC0000005: Access violation executing location 0x00007FFAC6E4E1A2.
Unhandled exception at 0x00007FFAC6E4E1A2 in silversim.exe: 0xC0000005: Access violation executing location 0x00007FFAC6E4E1A2.

I undo the code integration until I had just a simple QObject object; declaration inside a function. With this simple declaration the program exists with error, without any use of Qt objects the program exists normally.

What is happening here? Might be the static link to Qt? Maybe a bug in the Qt5.5 versions? Or something else from my program trying to deal qt .libs somehow during cleanup?

UPDATE

Thanks to IDA decompiler I managed to find out where the crash happens but still I don't know why. It crashes in void __fastcall qt_watch_adopted_thread(HANDLE hObject, struct QThread *). As I noticed, Qt creates some threads which are not destroyed when the program exits, and those threads try to access invalid memory. Maybe it is related with this opened qt bug: https://bugreports.qt.io/browse/QTBUG-40247 but in my case I'm not loading any plugin.

Ispas Claudiu
  • 1,890
  • 2
  • 28
  • 54
  • Can you show some code? Why are you using such an ancient Qt version? – Frank Osterfeld Jul 18 '19 at 09:42
  • There is a lot of code to show but I don't think it's relevant., because it is an old, well tested C++ code. A simple declaration of a Qt object anywhere in any function is enough to produce the error exit code. (also see the update) – Ispas Claudiu Jul 18 '19 at 09:59
  • blind guess: Qt's classes are supposed to be used within a QApplication. So you should probably create a Q(Core)Application object in your main() before doing anything else. – markus-nm Jul 18 '19 at 14:53
  • @markus-nm good hint. I'll try and let you know if it worked – Ispas Claudiu Jul 19 '19 at 08:39

0 Answers0