[Qt-interest] bad_alloc: Can't find what is causing it

Ori Lahav vbcrlf at gmail.com
Thu Jul 1 23:42:42 CEST 2010


I can't find the problem by reading the code. I tried Valgrind, but except
for the message QT shows:

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.*
*
*
*terminate called after throwing an instance of 'std::bad_alloc'*
*  what():  std::bad_alloc*

*It doesn't show any problem.
*
On Thu, Jul 1, 2010 at 8:49 PM, Jason H <scorp1us at yahoo.com> wrote:

> 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:
> 0 raise /lib/libc.so.6 0 0x00007ffff59b2565
> 1 abort /lib/libc.so.6 0 0x00007ffff59b39e6
> 2 __gnu_cxx::__verbose_terminate_handler() /usr/lib/libstdc++.so.6 0
> 0x00007ffff5fb206d
> 3 __cxxabiv1::__terminate(void (*)()) /usr/lib/libstdc++.so.6 0
> 0x00007ffff5fb0286
> 4 std::terminate() /usr/lib/libstdc++.so.6 0 0x00007ffff5fb02b3
> 5 __cxa_rethrow /usr/lib/libstdc++.so.6 0 0x00007ffff5fb0406
> 6 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)
> /usr/lib/libQtCore.so.4 0 0x00007ffff6354452
> 7 QCoreApplication::exec() /usr/lib/libQtCore.so.4 0 0x00007ffff635876b
> 8 main main.cpp 28 0x000000000040d21e
>
> 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/20100702/0084901f/attachment.html 


More information about the Qt-interest-old mailing list