PDA

View Full Version : QT 4.7.1 Win 7 x64 VS 2010: Debug works, Release crashes



new_voodoo
27th November 2010, 23:58
Hi.

The system is:
QT 4.7.1, Win 7 x64, VS 2010 Prof

I downloaded Qt 4.7.1(everywhere) from Nokia Ftp. Unzipped it and compiled it with x64 VS console.
Compilation worked, so that I recieved a debug and release dll.

My test program is very simple:



#ifdef _DEBUG
#pragma comment( lib, "QtMaind.lib" )
#pragma comment( lib, "QtGuid4.lib" )
#pragma comment( lib, "QtCored4.lib" )
#else
#pragma comment( lib, "QtMain.lib" )
#pragma comment( lib, "QtCore4.lib" )
#pragma comment( lib, "QtGui4.lib" )
#endif

int main(int argc, char** argv)
{

QApplication app( argc, argv ) ;

QTreeWidget* wg = new QTreeWidget() ;

wg->show() ;

//QWidget* wg2 = new QWidget() ;
//wg2->show() ;

return app.exec();
}



If I compile in debug mode, everything workds just fine.
BUT if I compile in release mode, the application crashes at app.exec().
The call stack shows the crash in QtGui4.dll.

If I change the line


QTreeWidget* wg = new QTreeWidget() ;
wg->show() ;

to


QTreeWidget* wg = new QTreeWidget() ;
//wg->show() ; // comment the show() here

the release mode compiled app suddenly works.

If I do this


QTreeWidget* wg = new QTreeWidget() ;
//wg->show() ;

QWidget* wg2 = new QWidget() ;
wg2->show() ;

the code also works just fine.

If I do this again:


QTreeWidget* wg = new QTreeWidget() ;
wg->show() ;

QWidget* wg2 = new QWidget() ;
wg2->show() ;

The application crashes again.

If I change from release to debug lib for QtGui.lib,


#ifdef _DEBUG
#pragma comment( lib, "QtMaind.lib" )
#pragma comment( lib, "QtGuid4.lib" )
#pragma comment( lib, "QtCored4.lib" )

#else // else use RELEASE

#pragma comment( lib, "QtMain.lib" )
#pragma comment( lib, "QtCore4.lib" )
#pragma comment( lib, "QtGuid4.lib" ) // HERE changed to debug lib! But here the release section resides!
#endif

everything works again. So there must be some kind of bug in the release build or I simply compiled my x64 qt wrong and the bug must be connected with QTreeWidget!
Because if I simply show the QWidget, the app runs, with QTreeWidget it doesn't run, it crashes as described.

The run-time error is:


Unhandled exception at 0x5cb96e5f in QtReleaseBuildTest.exe: 0xC0000005: Access violation reading location 0x0000000000000000.


Call stack is:


QtGui4.dll!000000005cb96e5f()
[Frames below may be incorrect and/or missing, no symbols loaded for QtGui4.dll]
QtGui4.dll!000000005cb96eee()
QtGui4.dll!000000005cbcfe77()
QtGui4.dll!000000005cbd2b37()
QtGui4.dll!000000005c7aa886()
QtGui4.dll!000000005caaef87()
QtGui4.dll!000000005cb98ed5()
QtCore4.dll!000000005d1a2c43()
QtGui4.dll!000000005c760382()
QtGui4.dll!000000005c7632e6()
QtCore4.dll!000000005d1a2ad2()
QtGui4.dll!000000005c7a8bcd()
QtGui4.dll!000000005c79ecaf()
QtGui4.dll!000000005c79eba2()
QtGui4.dll!000000005c7a8d5c()
QtGui4.dll!000000005c915f36()
QtGui4.dll!000000005c79dd68()
QtGui4.dll!000000005c7aac75()
QtGui4.dll!000000005caaef87()
QtGui4.dll!000000005cb20782()
QtGui4.dll!000000005c760396()
QtGui4.dll!000000005c7632e6()
QtCore4.dll!000000005d1a2ad2()
QtCore4.dll!000000005d1a44ea()
QtCore4.dll!000000005d1c5e0e()
user32.dll!00000000778cc3c1()
user32.dll!00000000778cc60a()
QtCore4.dll!000000005d1c7c7a()
QtGui4.dll!000000005c7c3dc5()
QtCore4.dll!000000005d1a202a()
QtCore4.dll!000000005d1a61c0()
> QtReleaseBuildTest.exe!main(int argc, char * * argv) Line 34 + 0x6 bytes C++
QtReleaseBuildTest.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C
kernel32.dll!00000000777af56d()
ntdll.dll!00000000779e3021()


Has somebody any idea?

Thanks

mattc
28th November 2010, 12:07
There are known problems with Qt and VS 2010 64 bit, see this bug report:
http://bugreports.qt.nokia.com/browse/QTBUG-11445

A patch from Microsoft is known to fix the problem above. Maybe you can try it as well.

new_voodoo
28th November 2010, 19:14
Hi and thanks a lot!

That patch worked!
I simply rebuild my Qt 4.7.1 package using the x64 VS2010 console and recompiled the application and bingo.

Thanks