-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValgrindDemoTest
executable file
·40 lines (38 loc) · 2.13 KB
/
ValgrindDemoTest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
gcc -g ValgrindDemo.c -o ValgrindDemo
valgrind ./ValgrindDemo --leak-check=full ./ValgrindDemo
###############################################################################
## [alison@bonnet GitTutorial]$ ./ValgrindDemoTest ##
## ==7304== Memcheck, a memory error detector ##
## ==7304== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.##
## ==7304== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info##
## ==7304== Command: ./ValgrindDemo --leak-check=full ./ValgrindDemo ##
## ==7304== ##
## ==7304== Invalid read of size 1 ##
## ==7304== at 0x400524: main (ValgrindDemo.c:15) ##
## ==7304== Address 0x4c20440 is 0 bytes after a block of size 1,024 alloc'd##
## ==7304== at 0x4A0515D: malloc (vg_replace_malloc.c:195) ##
## ==7304== by 0x400515: main (ValgrindDemo.c:11) ##
## ==7304== ##
## ==7304== Invalid write of size 1 ##
## ==7304== at 0x400534: main (ValgrindDemo.c:18) ##
## ==7304== Address 0x4c20440 is 0 bytes after a block of size 1,024 alloc'd##
## ==7304== at 0x4A0515D: malloc (vg_replace_malloc.c:195) ##
## ==7304== by 0x400515: main (ValgrindDemo.c:11) ##
## ==7304== ##
## ==7304== ##
## ==7304== HEAP SUMMARY: ##
## ==7304== in use at exit: 1,024 bytes in 1 blocks ##
## ==7304== total heap usage: 1 allocs, 0 frees, 1,024 bytes allocated##
## ==7304== ##
## ==7304== LEAK SUMMARY: ##
## ==7304== definitely lost: 1,024 bytes in 1 blocks ##
## ==7304== indirectly lost: 0 bytes in 0 blocks ##
## ==7304== possibly lost: 0 bytes in 0 blocks ##
## ==7304== still reachable: 0 bytes in 0 blocks ##
## ==7304== suppressed: 0 bytes in 0 blocks ##
## ==7304== Rerun with --leak-check=full to see details of leaked memory##
## ==7304== ##
## ==7304== For counts of detected and suppressed errors, rerun with: -v##
## ==7304== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 6 from 6)##
###############################################################################