PDA

View Full Version : How to debug Heap errors



sedi
17th June 2012, 14:43
Hi, wenn deleting an object (derived of a QGraphicsObject) I receive an error message:

Heap block at 0D6EC658 modified at 0D6EC700 past requested size of a0
The stacktrace shows nothing helpful (at least yet for me):

0 ntdll!TpWaitForAlpcCompletion C:\Windows\system32\ntdll.dll 0 0x77bf04e5
1 ?? 0 0x0028be90
2 ntdll!RtlLargeIntegerDivide C:\Windows\system32\ntdll.dll 0 0x77bd5732
3 ?? 0 0x0d5b82a0
4 ntdll!RtlCopyExtendedContext C:\Windows\system32\ntdll.dll 0 0x77bb29fa
5 ?? 0 0x00000000

(full Stacktrace attached)
The problem occurs when I allocate memory for a class member (QGraphicsRectItem*): whenever I initialize it with "new" the object will throw the above error on deletion.

This seems "funny" because I do that all the time in the base class of the same object (which base class is in turn the afore-mentioned QGraphicsObject): QGraphicsObject-->ButtonObject-->AppButton

As said: The ButtonObject has loads of QGraphicItems* of any kind and allocates them quite happily.

How can I trace the problem? It's about the first time I encounter this kind of error, therefore please don't assume common knowledge.

wysota
17th June 2012, 15:05
Backtrace won't help here. We'd need to see the actual code or you'd need to use a dedicated tool for tracing memory leaks.

sedi
17th June 2012, 22:16
Thank you, Wysota! What tracing tool would you recommend?
As the code is some 10.000 lines, spread over some 100 files it might be... ehm... quite impossible to "just post" it... :-)
Very fortunately this error magically went away by cleanup/qmake/rebuild all - I have no idea why such a thing is possible...

wysota
17th June 2012, 22:23
Thank you, Wysota! What tracing tool would you recommend?
If you were on Linux, I'd recommend valgrind, the best tool around. However it is not available for Windows so you need to look for Windows alternatives.


As the code is some 10.000 lines, spread over some 100 files it might be... ehm... quite impossible to "just post" it... :-)
No, but you can post the part you think is relevant to the problem.