==6018== Memcheck, a memory error detector ==6018== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==6018== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info ==6018== Command: ./test ==6018== ==6018== ==6018== HEAP SUMMARY: ==6018== in use at exit: 10 bytes in 1 blocks ==6018== total heap usage: 1 allocs, 0 frees, 10 bytes allocated ==6018== ==6018== 10 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==6018== at 0x4C2AC58: operator new[](unsigned long) (vg_replace_malloc.c:431) ==6018== by 0x40062E: func() (leak.cpp:4) ==6018== by 0x40063D: main (leak.cpp:8) ==6018== ==6018== LEAK SUMMARY: ==6018== definitely lost: 10 bytes in 1 blocks ==6018== indirectly lost: 0 bytes in 0 blocks ==6018== possibly lost: 0 bytes in 0 blocks ==6018== still reachable: 0 bytes in 0 blocks ==6018== suppressed: 0 bytes in 0 blocks ==6018== ==6018== For lists of detected and suppressed errors, rerun with: -s ==6018== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==22786== Memcheck, a memory error detector ==22786== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==22786== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info ==22786== Command: ./test ==22786== ==22786== Invalid write of size 1 // 内存越界 ==22786== at 0x4007FB: func() (mixed.cpp:6) ==22786== by 0x400851: main (mixed.cpp:18) ==22786== Address 0x5a2404a is 0 bytes after a block of size 10 alloc'd ==22786== at 0x4C2AC58: operator new[](unsigned long) (vg_replace_malloc.c:431) ==22786== by 0x4007EE: func() (mixed.cpp:5) ==22786== by 0x400851: main (mixed.cpp:18) ==22786== ==22786== Source and destination overlap in memcpy(0x5a24041, 0x5a24040, 5) // 踩内存 ==22786== at 0x4C2E83D: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1033) ==22786== by 0x400819: func() (mixed.cpp:8) ==22786== by 0x400851: main (mixed.cpp:18) ==22786== ==22786== Invalid free() / delete / delete[] / realloc() // 重复释放 ==22786== at 0x4C2BBAF: operator delete[](void*) (vg_replace_malloc.c:649) ==22786== by 0x40083F: func() (mixed.cpp:11) ==22786== by 0x400851: main (mixed.cpp:18) ==22786== Address 0x5a24040 is 0 bytes inside a block of size 10 free'd ==22786== at 0x4C2BBAF: operator delete[](void*) (vg_replace_malloc.c:649) ==22786== by 0x40082C: func() (mixed.cpp:10) ==22786== by 0x400851: main (mixed.cpp:18) ==22786== Block was alloc'd at ==22786== at 0x4C2AC58: operator new[](unsigned long) (vg_replace_malloc.c:431) ==22786== by 0x4007EE: func() (mixed.cpp:5) ==22786== by 0x400851: main (mixed.cpp:18) ==22786== ==22786== Use of uninitialised value of size 8 // 非法指针 ==22786== at 0x400844: func() (mixed.cpp:14) ==22786== by 0x400851: main (mixed.cpp:18) ==22786== ==22786== ==22786== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==22786== Bad permissions for mapped region at address 0x4008B0 ==22786== at 0x400844: func() (mixed.cpp:14) ==22786== by 0x400851: main (mixed.cpp:18) ==22786== ==22786== HEAP SUMMARY: ==22786== in use at exit: 0 bytes in 0 blocks ==22786== total heap usage: 1 allocs, 2 frees, 10 bytes allocated ==22786== ==22786== All heap blocks were freed -- no leaks are possible ==22786== ==22786== Use --track-origins=yes to see where uninitialised values come from ==22786== For lists of detected and suppressed errors, rerun with: -s ==22786== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0) Segmentation fault (core dumped)
==27722== Helgrind, a thread error detector ==27722== Copyright (C) 2007-2017, and GNU GPL'd, by OpenWorks LLP et al. ==27722== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info ==27722== Command: ./test ==27722== ==27722== ---Thread-Announcement------------------------------------------ ==27722== ==27722== Thread #3 was created ==27722== at 0x597589E: clone (in /usr/lib64/libc-2.17.so) ==27722== by 0x4E43059: do_clone.constprop.4 (in /usr/lib64/libpthread-2.17.so) ==27722== by 0x4E44569: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.17.so) ==27722== by 0x4C30CFA: pthread_create_WRK (hg_intercepts.c:425) ==27722== by 0x4C31DD8: pthread_create@* (hg_intercepts.c:458) ==27722== by 0x400728: main (helgrind.cpp:17) ==27722== ==27722== ---Thread-Announcement------------------------------------------ ==27722== ==27722== Thread #2 was created ==27722== at 0x597589E: clone (in /usr/lib64/libc-2.17.so) ==27722== by 0x4E43059: do_clone.constprop.4 (in /usr/lib64/libpthread-2.17.so) ==27722== by 0x4E44569: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.17.so) ==27722== by 0x4C30CFA: pthread_create_WRK (hg_intercepts.c:425) ==27722== by 0x4C31DD8: pthread_create@* (hg_intercepts.c:458) ==27722== by 0x40070D: main (helgrind.cpp:16) ==27722== ==27722== ---------------------------------------------------------------- ==27722== ==27722== Possible data race during read of size 4 at 0x601048 by thread #3 ==27722== Locks held: none ==27722== at 0x4006CE: threadfunc(void*) (helgrind.cpp:9) ==27722== by 0x4C30EEE: mythread_wrapper (hg_intercepts.c:387) ==27722== by 0x4E43EA4: start_thread (in /usr/lib64/libpthread-2.17.so) ==27722== by 0x59758DC: clone (in /usr/lib64/libc-2.17.so) ==27722== ==27722== This conflicts with a previous write of size 4 by thread #2 ==27722== Locks held: none ==27722== at 0x4006D9: threadfunc(void*) (helgrind.cpp:9) ==27722== by 0x4C30EEE: mythread_wrapper (hg_intercepts.c:387) ==27722== by 0x4E43EA4: start_thread (in /usr/lib64/libpthread-2.17.so) ==27722== by 0x59758DC: clone (in /usr/lib64/libc-2.17.so) ==27722== Address 0x601048 is 0 bytes inside data symbol "counter" ==27722== ==27722== ---------------------------------------------------------------- ==27722== ==27722== Possible data race during write of size 4 at 0x601048 by thread #3 ==27722== Locks held: none ==27722== at 0x4006D9: threadfunc(void*) (helgrind.cpp:9) ==27722== by 0x4C30EEE: mythread_wrapper (hg_intercepts.c:387) ==27722== by 0x4E43EA4: start_thread (in /usr/lib64/libpthread-2.17.so) ==27722== by 0x59758DC: clone (in /usr/lib64/libc-2.17.so) ==27722== ==27722== This conflicts with a previous write of size 4 by thread #2 ==27722== Locks held: none ==27722== at 0x4006D9: threadfunc(void*) (helgrind.cpp:9) ==27722== by 0x4C30EEE: mythread_wrapper (hg_intercepts.c:387) ==27722== by 0x4E43EA4: start_thread (in /usr/lib64/libpthread-2.17.so) ==27722== by 0x59758DC: clone (in /usr/lib64/libc-2.17.so) ==27722== Address 0x601048 is 0 bytes inside data symbol "counter" ==27722== counter = 90 ==27722== ==27722== Use --history-level=approx or =none to gain increased speed, at ==27722== the cost of reduced accuracy of conflicting-access information ==27722== For lists of detected and suppressed errors, rerun with: -s ==27722== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)