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

Konrad Rosenbaum konrad at silmor.de
Thu Jul 1 18:56:48 CEST 2010


On Thursday 01 July 2010, Ori Lahav wrote:
> 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?

I had problems like this quite a few times. It is most likely some part of 
your program is writing on memory that has already been freed or shoots over 
its allocated space. 

I used some length valgrind sessions to catch these. 

Don't be surprised if your program changes behaviour when being watched by 
gdb or valgrind - this is one of those obscure memory corruption moments 
which normally do not cause problems, because todays computers have quite a 
lot of memory, most of which does not care about corruption. Just look at 
the output of valgrind and check for signs of invalid memory access. 
Unfortunately, just like me, you'll have to learn to differentiate between 
signs and portents...


	Konrad



More information about the Qt-interest-old mailing list