The stack traces given by Memcheck on ARM are missing information

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The stack traces given by Memcheck on ARM are missing information

John O'Sullivan
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

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
Reply | Threaded
Open this post in threaded view
|

Re: The stack traces given by Memcheck on ARM are missing information

John O'Sullivan
I think I have found the issue, the libraries in /usr/lib/valgrind were
being stripped as part of the rootfs build, excluding these from
stripping now gives me

  valgrind --leak-check=full  --track-origins=yes --num-callers=4 /work/test
==1240== Memcheck, a memory error detector
==1240== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==1240== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==1240== Command: /work/test
==1240==
==1240== Invalid write of size 4
==1240==    at 0x8680: f (test.c:6)
==1240==    by 0x869B: main (test.c:13)
==1240==  Address 0x49b5050 is 0 bytes after a block of size 40 alloc'd
==1240==    at 0x4837774: malloc (vg_replace_malloc.c:270)
==1240==    by 0x866B: f (test.c:5)
==1240==    by 0x869B: main (test.c:13)
==1240==
==1240==
==1240== HEAP SUMMARY:
==1240==     in use at exit: 40 bytes in 1 blocks
==1240==   total heap usage: 1 allocs, 0 frees, 40 bytes allocated
==1240==
==1240== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1240==    at 0x4837774: malloc (vg_replace_malloc.c:270)
==1240==    by 0x866B: f (test.c:5)
==1240==    by 0x869B: main (test.c:13)
==1240==
==1240== LEAK SUMMARY:
==1240==    definitely lost: 40 bytes in 1 blocks
==1240==    indirectly lost: 0 bytes in 0 blocks

On 17/09/15 09:46, John O'Sullivan wrote:
> valgrind --leak-check=full  --track-origins=yes --num-callers=4 /work/test


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users