Valgrindでld-2.6.soでエラーが出る。
前にメモリリークを探してたときに使ってみて、えらく感激したValgrind。
ところが、最近VMに入れたFedora Core7でValgrindが上手く動かない。
a.cc
int main() { return 0; }
$ g++ a.cc $ valgrind --leak-check=full ./a.out |& less ==21301== Memcheck, a memory error detector. ==21301== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==21301== Using LibVEX rev 1732, a library for dynamic binary translation. ==21301== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==21301== Using valgrind-3.2.3, a dynamic binary instrumentation framework. ==21301== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==21301== For more details, rerun with: -v ==21301== ==21301== Conditional jump or move depends on uninitialised value(s) ==21301== at 0x78DBE3: _dl_relocate_object (in /lib/ld-2.6.so) ==21301== by 0x7868D8: dl_main (in /lib/ld-2.6.so) ==21301== by 0x796F6A: _dl_sysdep_start (in /lib/ld-2.6.so) ==21301== by 0x7842B7: _dl_start (in /lib/ld-2.6.so) ==21301== by 0x783816: (within /lib/ld-2.6.so) . . . ==21301== ==21301== Conditional jump or move depends on uninitialised value(s) ==21301== at 0x78DD25: _dl_relocate_object (in /lib/ld-2.6.so) ==21301== by 0x786A84: dl_main (in /lib/ld-2.6.so) ==21301== by 0x796F6A: _dl_sysdep_start (in /lib/ld-2.6.so) ==21301== by 0x7842B7: _dl_start (in /lib/ld-2.6.so) ==21301== by 0x783816: (within /lib/ld-2.6.so) ==21301== ==21301== ERROR SUMMARY: 15 errors from 8 contexts (suppressed: 0 from 0) ==21301== malloc/free: in use at exit: 0 bytes in 0 blocks. ==21301== malloc/free: 0 allocs, 0 frees, 0 bytes allocated. ==21301== For counts of detected errors, rerun with: -v ==21301== All heap blocks were freed -- no leaks are possible.
lib-2.6.soがだめっぽい。
コミットログを読んでいたら、2007-05-24 Rev.6744にglibc 2.6 supportと書いてあったので、
yumで入れた3.2.3を捨てて3.3.0.SVNを入れてみることに。
$ sudo yum remove valgrind
$ svn co svn://svn.valgrind.org/valgrind/trunk valgrind
$ cd valgrind
$ ./autogen.sh
$ make
$ sudo make install
$ valgrind --leak-check=full ./a.out |& less ==29561== Memcheck, a memory error detector. ==29561== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==29561== Using LibVEX rev 1775, a library for dynamic binary translation. ==29561== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==29561== Using valgrind-3.3.0.SVN, a dynamic binary instrumentation framework. ==29561== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==29561== For more details, rerun with: -v ==29561== ==29561== ==29561== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 15 from 1) ==29561== malloc/free: in use at exit: 0 bytes in 0 blocks. ==29561== malloc/free: 0 allocs, 0 frees, 0 bytes allocated. ==29561== For counts of detected errors, rerun with: -v ==29561== All heap blocks were freed -- no leaks are possible.
ld-2.6.soで文句は言わなくなった。
一応、ちゃんとリークを検出してくるかも試してみる。
a.cc
int main() { int* p = new int; return 0; }
$ g++ a.cc $ valgrind --leak-check=full ./a.out 2| less ==29603== Memcheck, a memory error detector. ==29603== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==29603== Using LibVEX rev 1775, a library for dynamic binary translation. ==29603== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==29603== Using valgrind-3.3.0.SVN, a dynamic binary instrumentation framework. ==29603== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==29603== For more details, rerun with: -v ==29603== ==29603== ==29603== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 16 from 1) ==29603== malloc/free: in use at exit: 4 bytes in 1 blocks. ==29603== malloc/free: 1 allocs, 0 frees, 4 bytes allocated. ==29603== For counts of detected errors, rerun with: -v ==29603== searching for pointers to 1 not-freed blocks. ==29603== checked 92,764 bytes. ==29603== ==29603== 4 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==29603== at 0x4005D4C: operator new(unsigned) (vg_replace_malloc.c:221) ==29603== by 0x8048490: main (in /home/tetsujin/work/val/a.out) ==29603== ==29603== LEAK SUMMARY: ==29603== definitely lost: 4 bytes in 1 blocks. ==29603== possibly lost: 0 bytes in 0 blocks. ==29603== still reachable: 0 bytes in 0 blocks. ==29603== suppressed: 0 bytes in 0 blocks.
とりあえずOKかな。