Windows Desktop GUI App crashes when release mode is run. But does not crash when debug mode is run.



  • I have this strange problem where running the release version of my GUI on Windows crashes at startup and prints out the following [abridged] output:

    Starting C:........\build-WindowsUI-Desktop_Qt_5_4_0_MSVC2010_OpenGL_32bit-Release\release\WindowsUI.exe...
    The program has unexpectedly finished.
    C:.............\build-WindowsUI-Desktop_Qt_5_4_0_MSVC2010_OpenGL_32bit-Release\release\WindowsUI.exe crashed

    There is no other information given. Compiler output seems normal and no crash detailed information is printed. When I run the debug version: everything is fine. The GUI runs normally and no problems encountered.

    Has anyone else encountered something like this before? I'm stuck here.



  • @mrjextreme6 Hi, I would suggest taking the conventional approach to insert qDebug() << "..."; markers so that you can find out how far your program proceeds.
    Also a good candidate for this behaviour could be un-initialized class members.
    Don't forget to enable console output on windows by adding CONFIG += console to your pro file.



  • When I get that kind of behaviour I always suspect I've used a deleted an uninitialized pointer.
    OR perhaps double deleted something.

    You may wish to consider using QScopedPointer to handle the deletion of pointers.

    If you are really stuck as you say, then be ready to to use lots of qDebug!
    Check your constructors set ALL your pointers to NULL/nullptr if they are not initialized.
    When you delete a pointer, set it to NULL/nullptr afterwards.

    Alternatively, perhaps, make a simple test program.
    You can run the debugger on the release build... but its not easy going.



  • @mrjextreme6

    The above suggestions are spot on. One thing... Are you "running" your app straight from Windows or from Qt development environment?

    The reason I ask is that when I was first deploying my app I got the same behavior. It just crashed unfortunately I was at the client and just trying to get it working. I didn't have much time to liter more qdebug stuff. (I did after).

    What I found was I was missing a number of key DLLs in the path. The symptom was just a total crash rather than some message. I had run dependency checker and thought I had what was needed. Nope...

    To solve the immediate problem and get the app up and running I ended up downloading and installing VS2013 community edition which installed the right runtimes that were needed and it just started to work. (my compiler is VS2013)

    After that experience and sweat I created a generic Windows 7 VM and did install after install until I could get the app to run. Before I deploy any new version I repeat the process checking that I have everything needed.

    Hope the above hints and this help!



  • @SysTech said:

    After that experience and sweat I created a generic Windows 7 VM and did install after install until I could get the app to run. Before I deploy any new version I repeat the process checking that I have everything needed.

    Indeed a very good hint that in my opinion everyone should follow! I once fell for the plugins issue: Running the application on a Windows system with Qt SDK installed ran fine, on the target system not because of the missing qwindows.dll plugin. Admittingly that was before I found the excellent deployment documentation on the wiki...



  • Thank you everyone :)

    I followed simow and SysTech's suggestions and used QDebug to find the problem. I found my program crashed when entering a certain set of libraries so I ran the release executable through the debugger. The stack trace of the assembly revealed that my code was using the debug versions of my third party dlls even though I thought I specified my project to not use them in the release version. I modified the .pro file in qtcreator and now everything works properly. Thanks!!!



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.