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)
Re: how to get proper stack trace
What is your code doing around line 181 in main.cpp?
Re: how to get proper stack trace
main.cpp:181
return app.exec();
it is end of the main func, app = QApplication
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.
Re: how to get proper stack trace
What do you do just before main.cpp:181?
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
Re: how to get proper stack trace
Are you throwing any exceptions or using a library that might be throwing exceptions?
Re: how to get proper stack trace
Yes, I use try{}catch{} exceptions. The segfault comes in std::vector out-of-range request.
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).
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)
Re: how to get proper stack trace
Quote:
Originally Posted by
musla
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.
Quote:
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.
Quote:
:( 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.
Quote:
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.