root@meituanyun:~/mycode# valgrind --leak-check=full ./test4
==26072== Memcheck, a memory error detector
==26072== Copyright (C) 2002-2015, andGNUGPL'd, by Julian Seward et al.
==26072== UsingValgrind-3.11.0andLibVEX; rerun with -h for copyright info
==26072== Command: ./test4
==26072==
==26072== Invalid write of size 1==26072== at 0x400663: main (test4.c:8)
==26072== Address0x520404c is 2 bytes after a block of size 10 alloc'd
==26072== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26072== by 0x400656: main (test4.c:7)
==26072==
==26072== Sourceand destination overlap in memcpy(0x5204041, 0x5204040, 5)
==26072== at 0x4C32513: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26072== by 0x400681: main (test4.c:9)
==26072==
==26072== Invalid free() / delete / delete[] / realloc()
==26072== at 0x4C2EDEB: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26072== by 0x40069D: main (test4.c:13)
==26072== Address0x5204040 is 0 bytes inside a block of size 10 free'd
==26072== at 0x4C2EDEB: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26072== by 0x400691: main (test4.c:12)
==26072== Block was alloc'd at
==26072== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26072== by 0x400656: main (test4.c:7)
==26072==
==26072== Use of uninitialised value of size 8==26072== at 0x4006A2: main (test4.c:15)
==26072==
==26072== Invalid write of size 1==26072== at 0x4006A2: main (test4.c:15)
==26072== Address0x0 is not stack'd, malloc'd or (recently) free'd
==26072==
==26072==
==26072== Process terminating with default action of signal 11 (SIGSEGV)
==26072== Accessnot within mapped region at address 0x0==26072== at 0x4006A2: main (test4.c:15)
==26072== If you believe this happened as a result of a stack
==26072== overflow in your program's main thread (unlikely but
==26072== possible), you can try to increase the size of the
==26072== main thread stack using the --main-stacksize= flag.
==26072== The main thread stack size used in this run was 8388608.
==26072==
==26072== HEAPSUMMARY:==26072== in use at exit:0 bytes in0 blocks
==26072== total heap usage:1 allocs, 2 frees, 10 bytes allocated
==26072==
==26072== All heap blocks were freed -- no leaks are possible
==26072==
==26072== For counts of detected and suppressed errors, rerun with: -v
==26072== Use --track-origins=yes to see where uninitialised values come from
==26072== ERRORSUMMARY:5 errors from 5 contexts (suppressed:0 from 0)
Segmentation fault (core dumped)