Results 1 to 11 of 11

Thread: how to get proper stack trace

  1. #1
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default how to get proper stack trace

    Hello,
    I need to debug runtime error produced by other library that is linked in shared object (QT plugin system).
    When using gdb or MSVC++ debugger, I always get irrelevant stact trace pointing to QEventLoop and the message:

    Qt has caught an exception thrown from an event handler. Throwing
    exceptions from an event handler is not supported in Qt. You must
    reimplement QApplication::notify() and catch all exceptions there.

    How can I get the stack trace from the code, that really causes the crash? I know that the error comes from wrong accessing of stl::vector object. All libs are compiled with debug flag.

    I tried MSVC++ debugger as well as gdb with same results

    Thanks in advance,
    Tomas

    (gdb)
    #0 0x00007f4f3643a095 in raise () from /lib/libc.so.6
    #1 0x00007f4f3643baf0 in abort () from /lib/libc.so.6
    #2 0x00007f4f36cbf0e4 in __gnu_cxx::__verbose_terminate_handler ()
    from /usr/lib/libstdc++.so.6
    #3 0x00007f4f36cbd076 in ?? () from /usr/lib/libstdc++.so.6
    #4 0x00007f4f36cbd0a3 in std::terminate () from /usr/lib/libstdc++.so.6
    #5 0x00007f4f36cbd121 in __cxa_rethrow () from /usr/lib/libstdc++.so.6
    #6 0x00007f4f3802f61a in QEventLoop::exec (this=0x7fff467a3650,
    flags=@0x7fff467a3660) at kernel/qeventloop.cpp:199
    #7 0x00007f4f38031529 in QCoreApplication::exec ()
    at kernel/qcoreapplication.cpp:845
    #8 0x0000000000421f79 in main (argc=1, argv=0x7fff467a3b38) at main.cpp:181
    (gdb)

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

    Default Re: how to get proper stack trace

    What is your code doing around line 181 in main.cpp?

  3. #3
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get proper stack trace

    main.cpp:181
    return app.exec();
    it is end of the main func, app = QApplication

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

    Default Re: how to get proper stack trace

    It's a safe bet that the problem lies somewhere in your code, rather than Qt's. Not a sure bet, perhaps, but a safe one.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to get proper stack trace

    What do you do just before main.cpp:181?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get proper stack trace

    Yes, the problem lies in my code. The segfault produces my code, but I need to debug it and get correct stack trace...that's what I need.

    In the main() I instantiate my core object with all the Qt UI objects, scripting engine, etc...
    Just before l.181:

    QString initJS = core.findFile("init.js");
    if (initJS!="") {
    core.include("init.js");
    }

    Where core is my object, init.js is a ECMAScript file, that is evaluated and executed.
    But I guess, this will not help....
    Many thanks,

    Tomas

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to get proper stack trace

    Are you throwing any exceptions or using a library that might be throwing exceptions?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get proper stack trace

    Yes, I use try{}catch{} exceptions. The segfault comes in std::vector out-of-range request.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to get proper stack trace

    Please show us the complete method containing the try-catch block and tell us when the method is invoked (it's best if you provide a stack trace).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jun 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get proper stack trace

    Hi wysota,

    the whole application is quite complicated and the error occurs in 3rd party library:
    The app starts with Qt initialization, creates my core (QObject subclass) object. Core has built scripting support and plugin system. One of the plugins is linked with OpenMesh library. This library causes somewhere crash (i would like to find where). The OpenMesh code contrains try-catch blocks and from the Qt output (Qt has caught an exception thrown) I guess that exception in OpenMesh (or stl that is used) was thrown. The stack trace is in my first post - from stl directly do QEventLoop I'd like to see complete stack trace - which call caused stl to thrown an exception.
    I would like to show you the method containing try-catch block, but I'm afraid I do know how...

    Generally: if Qt application code throwns an exception that is not catched up to Qt Qt::notify, can I somehow get the stack trace? (I got the one in 1st post)

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to get proper stack trace

    Quote Originally Posted by musla View Post
    the whole application is quite complicated and the error occurs in 3rd party library:
    The app starts with Qt initialization, creates my core (QObject subclass) object. Core has built scripting support and plugin system. One of the plugins is linked with OpenMesh library. This library causes somewhere crash (i would like to find where). The OpenMesh code contrains try-catch blocks and from the Qt output (Qt has caught an exception thrown) I guess that exception in OpenMesh (or stl that is used) was thrown.
    So embed all calls to OpenMesh with a try-catch block.

    The stack trace is in my first post - from stl directly do QEventLoop
    I meant the stack trace from a method that throws the exception. You have to set a breakpoint and optionally step through the library code until you reach a point where it aborts. And since OpenMesh is "open", I assume there is a source code to look at and a version of the library with debugging symbols available.

    I'd like to see complete stack trace
    This is a complete trace. Just not in a place where it has anything useful to say.

    I would like to show you the method containing try-catch block, but I'm afraid I do know how...
    grep -R "throw" * is a good thing to start with. But most likely you won't find anything this way. You need to set a breakpoint and trace the problem manually.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 27th April 2011, 19:44
  2. QObject in stack...??
    By joseph in forum Qt Programming
    Replies: 11
    Last Post: 30th October 2007, 08:17
  3. trace new files in a directory
    By Fastman in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 12:04
  4. Replies: 1
    Last Post: 22nd January 2007, 12:13
  5. stack
    By mickey in forum General Programming
    Replies: 7
    Last Post: 20th November 2006, 14:15

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.