I would like to try using valgrind to detect heap. At the following unit test "failure:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
char * c = (char *) malloc(10) ;
memset( c, 0xAB, 20 ) ;
printf("not aborted\n") ;
return 0 ;
}
I was surprised to find that valgrind does not interrupt the error, but simply creates a message:
valgrind -q --leak-check = no a.out
== 11097 == Invalid write of size 4
== 11097 == at 0x40061F: main (in /home/hotellnx94/peeterj/tmp/a.out)
== 11097 == Address 0x51c6048 is 8 bytes inside a block of size 10 alloc'd
== 11097 == at 0x4A2058F: malloc (vg_replace_malloc.c: 236)
== 11097 == by 0x400609: main (in /home/hotellnx94/peeterj/tmp/a.out)
...
not aborted
valgrind (, gnu-libc mcheck , mcheck, ). - , ( dup2 stdout to/dev/null, , , ).