View Full Version : Throwing exception crashes app

13th September 2011, 22:23
I have a big issue with exceptions. I have change our compilation enviroment to use qmake to buils makefiles depending on the platform.
When testing the application i found that everytime an exception is thrown the app crashes with a runtime exception. (we are on windows 7 32bits)

So i made a silly main.cpp to see if the exception was the problem, and it confirmed it.

#include <iostream>
#include <exception>
#include <QDebug>

void tiraException()
std::exception e;
throw e;

int main()
qDebug() << "initiating test...";

catch (...)
qDebug() << "error: excepcion!";

return 0;

This simple program crashes when throwign the exception.... any ideas? everything is in default state (building enviroment, using qt creator's mingw)

help will be much apreciated!

13th September 2011, 22:39
initiating test...
error: excepcion!
Press <RETURN> to close this window...

13th September 2011, 22:42
damn... i've just found out that there's a bug on gcc 4.4 with mingw. That is exactly what Qt Creator 2.3 and 2.2.1 is shipped with. I guess u have another version or somehow using another gcc.

did u build and run with creator?

14th September 2011, 15:58
well i just cant make it work. Im building and running with Creator, using Mingw. If i change the "qDebug()" for "std::cout" then it works....
There must be some kind of workaround, otherwhise we will have to definitely forget about building and runing apps with creator, at least on windows.

I'd really apreciate the comment of someone from the Qt team.

Almeto: could tell me how your enviroment is? platform, compiler, Ide and version, qt library version.


14th September 2011, 17:05
It's been a while since I've built Qt, but as I recall one of the configure settings enabled/disabled support for C++ exceptions. I have no idea whether this is still part of configuration, or what the default is, but perhaps it's worth looking into.

14th September 2011, 19:23
you know what, in the meanwhile I have installed win debug tools. Now It wont link because it can't find kernel32.lib. But it wasn't doing that before...

15th September 2011, 16:44
So i decided to compile Qt statically and start from scratch with only that version. It took 6hs to compile, now i have Qt Creator 2.3 using ONLY the MinGW i've downloaded before (with gcc 4.5) and Qt static libraries. Everything is working fine, so i guess dll issues when compiling and then linking and loading in runtime was causing the issue. Compiling with some library and using another on runtime.

The only thing remaining now is to figure out a way of reducing the excecutable size, since now a simple test takes too much to compile and 150mb.