baiduhook icon indicating copy to clipboard operation
baiduhook copied to clipboard

valgrind检测出问题

Open GoogleCodeExporter opened this issue 9 years ago • 0 comments

$ valgrind --leak-check=full ./test_class                                       

[/home/google/bhook-1.0.0/test/unittest/class][16:47:01]
==17210== Memcheck, a memory error detector
==17210== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==17210== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==17210== Command: ./test_class
==17210== 
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from Person
[ RUN      ] Person.PublicSay
[=HOOK=] this is no PublicSay!
test_class.cpp:53: Failure
Value of: ret
  Actual: -1
Expected: 0
[  FAILED  ] Person.PublicSay (66 ms)
[ RUN      ] Person.PrivateSay
[=HOOK=] this is no PrivateSay!
test_class.cpp:67: Failure
Value of: ret
  Actual: -2
Expected: 0
[  FAILED  ] Person.PrivateSay (15 ms)
[----------] 2 tests from Person (93 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 1 test case ran. (137 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 2 tests, listed below:
[  FAILED  ] Person.PublicSay
[  FAILED  ] Person.PrivateSay

 2 FAILED TESTS
end test.....
==17210== Invalid read of size 8
==17210==    at 0x588B758: std::vector<testing::internal::String, 
std::allocator<testing::internal::String> >::~vector() (stl_construct.h:103)
==17210==    by 0x6537E3E: __cxa_finalize (cxa_finalize.c:55)
==17210==    by 0x5ABA752: ??? (in /usr/lib/libgtestmain.so.0.0.0)
==17210==    by 0x400EFEE: _dl_fini (dl-fini.c:253)
==17210==    by 0x6537AA0: __run_exit_handlers (exit.c:77)
==17210==    by 0x6537B24: exit (exit.c:99)
==17210==    by 0x651F99B: (below main) (libc-start.c:294)
==17210==  Address 0x7799b80 is 0 bytes inside a block of size 16 free'd
==17210==    at 0x4C2A64C: operator delete(void*) (vg_replace_malloc.c:480)
==17210==    by 0x6537E3E: __cxa_finalize (cxa_finalize.c:55)
==17210==    by 0x5876612: ??? (in /usr/lib/libgtest.so.0.0.0)
==17210==    by 0x400EFEE: _dl_fini (dl-fini.c:253)
==17210==    by 0x6537AA0: __run_exit_handlers (exit.c:77)
==17210==    by 0x6537B24: exit (exit.c:99)
==17210==    by 0x651F99B: (below main) (libc-start.c:294)
==17210== 
==17210== Invalid free() / delete / delete[] / realloc()
==17210==    at 0x4C2A0CC: operator delete[](void*) (vg_replace_malloc.c:515)
==17210==    by 0x588B764: std::vector<testing::internal::String, 
std::allocator<testing::internal::String> >::~vector() (gtest-string.h:218)
==17210==    by 0x6537E3E: __cxa_finalize (cxa_finalize.c:55)
==17210==    by 0x5ABA752: ??? (in /usr/lib/libgtestmain.so.0.0.0)
==17210==    by 0x400EFEE: _dl_fini (dl-fini.c:253)
==17210==    by 0x6537AA0: __run_exit_handlers (exit.c:77)
==17210==    by 0x6537B24: exit (exit.c:99)
==17210==    by 0x651F99B: (below main) (libc-start.c:294)
==17210==  Address 0x7799bd0 is 0 bytes inside a block of size 13 free'd
==17210==    at 0x4C2A0CC: operator delete[](void*) (vg_replace_malloc.c:515)
==17210==    by 0x588B764: std::vector<testing::internal::String, 
std::allocator<testing::internal::String> >::~vector() (gtest-string.h:218)
==17210==    by 0x6537E3E: __cxa_finalize (cxa_finalize.c:55)
==17210==    by 0x5876612: ??? (in /usr/lib/libgtest.so.0.0.0)
==17210==    by 0x400EFEE: _dl_fini (dl-fini.c:253)
==17210==    by 0x6537AA0: __run_exit_handlers (exit.c:77)
==17210==    by 0x6537B24: exit (exit.c:99)
==17210==    by 0x651F99B: (below main) (libc-start.c:294)
==17210== 
==17210== Invalid free() / delete / delete[] / realloc()
==17210==    at 0x4C29C64: calloc (vg_replace_malloc.c:593)
==17210==    by 0x4010F29: allocate_dtv (dl-tls.c:296)
==17210==    by 0x401163D: _dl_allocate_tls (dl-tls.c:460)
==17210==    by 0x564B5B8: pthread_create@@GLIBC_2.2.5 (allocatestack.c:579)
==17210==    by 0x4094A8: Message::Init(int (*)(FaultUnit const&, char*, int)) 
(Message.cpp:43)
==17210==    by 0x4047A3: Core::Init() (Core.cpp:34)
==17210==    by 0x404889: Core::getInstance() (Core.cpp:81)
==17210==    by 0x403FE0: attach_func_lib(char*, void*) (bhook.cpp:74)
==17210==    by 0x40306C: main (test_class.cpp:77)
==17210== 
==17210== 2,857 bytes in 1 blocks are definitely lost in loss record 189 of 190
==17210==    at 0x4C2BE2B: malloc (vg_replace_malloc.c:270)
==17210==    by 0x409A83: ELFManager::elf_canonicalize_symbol(elf_symbol**, 
unsigned int) (ELFManager.cpp:59)
==17210==    by 0x406623: BinaryFile::InitRelsym(std::map<std::string, 
BinaryFile::RelSym, std::less<std::string>, 
std::allocator<std::pair<std::string const, BinaryFile::RelSym> > >&) 
(BinaryFile.cpp:242)
==17210==    by 0x406E3D: BinaryFile::Init(char*) (BinaryFile.cpp:61)
==17210==    by 0x404105: HookManager::Init() (HookManager.cpp:48)
==17210==    by 0x404779: Core::Init() (Core.cpp:27)
==17210==    by 0x404889: Core::getInstance() (Core.cpp:81)
==17210==    by 0x403FE0: attach_func_lib(char*, void*) (bhook.cpp:74)
==17210==    by 0x40306C: main (test_class.cpp:77)
==17210== 
==17210== 14,549 bytes in 1 blocks are definitely lost in loss record 190 of 190
==17210==    at 0x4C2BE2B: malloc (vg_replace_malloc.c:270)
==17210==    by 0x409A83: ELFManager::elf_canonicalize_symbol(elf_symbol**, 
unsigned int) (ELFManager.cpp:59)
==17210==    by 0x405B20: BinaryFile::InitSymbols(std::map<std::string, 
BinaryFile::Symbol, std::less<std::string>, 
std::allocator<std::pair<std::string const, BinaryFile::Symbol> > >&, int) 
(BinaryFile.cpp:146)
==17210==    by 0x406E2D: BinaryFile::Init(char*) (BinaryFile.cpp:56)
==17210==    by 0x404105: HookManager::Init() (HookManager.cpp:48)
==17210==    by 0x404779: Core::Init() (Core.cpp:27)
==17210==    by 0x404889: Core::getInstance() (Core.cpp:81)
==17210==    by 0x403FE0: attach_func_lib(char*, void*) (bhook.cpp:74)
==17210==    by 0x40306C: main (test_class.cpp:77)
==17210== 
==17210== LEAK SUMMARY:
==17210==    definitely lost: 17,509 bytes in 10 blocks
==17210==    indirectly lost: 0 bytes in 0 blocks
==17210==      possibly lost: 437 bytes in 4 blocks
==17210==    still reachable: 6,888 bytes in 176 blocks
==17210==         suppressed: 0 bytes in 0 blocks
==17210== Reachable blocks (those to which a pointer was found) are not shown.
==17210== To see them, rerun with: --leak-check=full --show-reachable=yes
==17210== 
==17210== For counts of detected and suppressed errors, rerun with: -v
==17210== ERROR SUMMARY: 24 errors from 18 contexts (suppressed: 2 from 2)

Original issue reported on code.google.com by [email protected] on 23 Jul 2013 at 9:06

GoogleCodeExporter avatar Jan 04 '16 11:01 GoogleCodeExporter