Results 1 to 7 of 7

Thread: Throwing exception crashes app

  1. #1
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Throwing exception crashes app

    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.
    Qt Code:
    1. #include <iostream>
    2. #include <exception>
    3. #include <QDebug>
    4.  
    5. void tiraException()
    6. {
    7. std::exception e;
    8. throw e;
    9. }
    10.  
    11.  
    12. int main()
    13. {
    14. qDebug() << "initiating test...";
    15.  
    16. try
    17. {
    18. tiraException();
    19. }
    20. catch (...)
    21. {
    22. qDebug() << "error: excepcion!";
    23. }
    24.  
    25. return 0;
    26. }
    To copy to clipboard, switch view to plain text mode 

    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!

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Throwing exception crashes app

    initiating test...
    error: excepcion!
    Press <RETURN> to close this window...

  3. #3
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Throwing exception crashes app

    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?

  4. #4
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Throwing exception crashes app

    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.

    Thanks!

  5. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Throwing exception crashes app

    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.

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Throwing exception crashes app

    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...

  7. #7
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Throwing exception crashes app

    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.

Similar Threads

  1. Replies: 5
    Last Post: 6th September 2011, 23:19
  2. Replies: 5
    Last Post: 16th March 2011, 16:02
  3. exception
    By AnithaRagupathy in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 09:59
  4. Unhandled Exception Err
    By Masih in forum Newbie
    Replies: 9
    Last Post: 25th July 2007, 20:28
  5. Exception handling in Qt 4.2.2
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2007, 09:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.