Hi,
I have recently managed to get Valgrind running on an ARM Zynq Cortex
A9 based embedded system. I have a simple test program as shown, the
output is shown below,
Does anyone know why this in the case of the output for the memory leak
there is not a full stack trace.
at 0x4837774: malloc (in /usr/lib/valgrind/vgpreload_memcheck-arm-linux.so)
I use gdbserver and eclipse based gdb debugging on this system and have
no difficulty getting full stack traces so I would like to understand if
it is possible to locate actual source of memory leaks.
I have read the advice given at
http://valgrind.org/docs/manual/faq.html#faq.unhelpful
---------------------------------------------------------------
compiled with the following cflags
-funwind-tables -mapcs-frame -fno-omit-frame-pointer -fno-stack-check -O0
#include <stdlib.h>
void f()
{
int * x = malloc(10 * sizeof(int));
x[10] = 0; // problem 1: heap block overrun
} // problem 2: memory leak -- x not freed
int main(void)
{
f();
return 0;
}
valgrind --leak-check=full --track-origins=yes --num-callers=4 /work/test
==10738== Memcheck, a memory error detector
==10738== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==10738== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==10738== Command: /work/test
==10738==
==10738== Invalid write of size 4
==10738== at 0x8680: f (test.c:6)
==10738== by 0x869B: main (test.c:13)
==10738== Address 0x49b5050 is 0 bytes after a block of size 40 alloc'd
==10738== at 0x4837774: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-arm-linux.so)
==10738==
==10738==
==10738== HEAP SUMMARY:
==10738== in use at exit: 40 bytes in 1 blocks
==10738== total heap usage: 1 allocs, 0 frees, 40 bytes allocated
==10738==
==10738== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1
==10738== at 0x4837774: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-arm-linux.so)
==10738==
==10738== LEAK SUMMARY:
==10738== definitely lost: 40 bytes in 1 blocks
==10738== indirectly lost: 0 bytes in 0 blocks
==10738== possibly lost: 0 bytes in 0 blocks
==10738== still reachable: 0 bytes in 0 blocks
==10738== suppressed: 0 bytes in 0 blocks
==10738==
==10738== For counts of detected and suppressed errors, rerun with: -v
==10738== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 13 from 6)
Regards
John
|