[Qt-interest] bad_alloc: Can't find what is causing it
Jason H
scorp1us at yahoo.com
Thu Jul 1 19:49:02 CEST 2010
Heap corruption comes from double-freeing the same block twice. I..e. a pointer so some is used to free, then the actual object itself if freed. For simplicity, make sure only the creating object frees what it created, unless there is a clear hand-off of ownership.
There can also be instances where you just completely overwrite bounds of what you alloc'd and end up corrupting the rest of the heap. These are the easiest to fix, as everything should be bounds-checked anyway, especially when writing memory. If you don't then you're crating a buffer-overflow exploit.
________________________________
From: Ori Lahav <vbcrlf at gmail.com>
To: qt-interest <qt-interest at trolltech.com>
Sent: Thu, July 1, 2010 6:08:38 AM
Subject: [Qt-interest] bad_alloc: Can't find what is causing it
Hello,
QT says I've got a std::bad_alloc exception, and close the program. I look at the stack and it is from the QEventLoop. Here's the full stack trace:
0raise/lib/libc.so.600x00007ffff59b2565
1abort/lib/libc.so.600x00007ffff59b39e6
2__gnu_cxx::__verbose_terminate_handler()/usr/lib/libstdc++.so.600x00007ffff5fb206d
3__cxxabiv1::__terminate(void (*)())/usr/lib/libstdc++.so.600x00007ffff5fb0286
4std::terminate()/usr/lib/libstdc++.so.600x00007ffff5fb02b3
5__cxa_rethrow/usr/lib/libstdc++.so.600x00007ffff5fb0406
6QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)/usr/lib/libQtCore.so.400x00007ffff6354452
7QCoreApplication::exec()/usr/lib/libQtCore.so.400x00007ffff635876b
8mainmain.cpp280x000000000040d21e
If the window is not focused, no exception is thrown - only when I switch to the window I get this exception. It is somehow related to events.
(I know what I did before it started to happen, but my program is pretty complicated now, so it is hard to find why the change is causing it without a useful stack trace)
How can I find what causes this error?
Thanks!
Ori.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100701/f6abb3ed/attachment.html
More information about the Qt-interest-old
mailing list