如何在Valgrind中发现被抑制的错误?

时间:2011-09-28 07:19:00

标签: c memory memory-management memory-leaks valgrind

我有以下valgrind输出:

==28099== 
==28099== HEAP SUMMARY: 
==28099==     in use at exit: 0 bytes in 0 blocks
==28099==   total heap usage: 131 allocs, 131 frees, 3,472 bytes allocated
==28099== 
==28099== All heap blocks were freed -- no leaks are possible
==28099== 
==28099== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)
--28099-- 
--28099-- used_suppression:      2 dl-hack3-cond-1
--28099-- used_suppression:      2 glibc-2.5.x-on-SUSE-10.2-(PPC)-2a
==28099== 
==28099== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)

有4个被抑制的错误。虽然这里没有泄漏,但在移植到另一个系统时创建了问题。

[编辑]

我也使用 valgrind -v 选项重新运行。但我没有发现任何错误。

 ==30287== Memcheck, a memory error detector  
 ==30287== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
 ==30287== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
 ==30287== Command: ./EXECUTABLE1 test_input.txt 
 ==30287== 
 --30287-- Valgrind options:
 --30287--    --suppressions=/usr/lib/valgrind/debian-libc6-dbg.supp
 --30287--    -v
 --30287--    --gen-suppressions=all
 --30287--    --error-limit=no
 --30287-- Contents of /proc/version:
 --30287--   Linux version 2.6.38.3.2.amd64-smp (gcc version 4.4.5   (Debian 4.4.5-8) ) #1 SMP Wed Apr 20 17:36:19 CEST 2011
 --30287-- Arch and hwcaps: AMD64, amd64-sse3-cx16
 --30287-- Page sizes: currently 4096, max supported 4096
 --30287-- Valgrind library directory: /usr/lib/valgrind
 --30287-- Reading syms from /home/path/to/file(0x400000)
 --30287-- Reading syms from /lib/ld-2.11.2.so (0x4000000)
 --30287--   Considering /lib/ld-2.11.2.so ..
 --30287--   .. CRC mismatch (computed cd91cee9 wanted 11b4673c)
 --30287--   Considering /usr/lib/debug/lib/ld-2.11.2.so ..
 --30287--   .. CRC is valid
 --30287-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux (0x38000000)
 --30287--    object doesn't have a dynamic symbol table
 --30287-- Reading suppressions file: /usr/lib/valgrind/debian-libc6-dbg.supp
 --30287-- Reading suppressions file: /usr/lib/valgrind/default.supp
  --30287-- REDIR: 0x4016230 (strlen) redirected to 0x380408a7 (vgPlain_amd64_linux_REDIR_FOR_strlen)
 --30287-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so (0x4a20000)
  --30287-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so (0x4c21000)
  ==30287== WARNING: new redirection conflicts with existing -- ignoring it 
  --30287--     new: 0x04016230 (strlen              ) R-> 0x04c25850 strlen
  --30287-- REDIR: 0x40160a0 (index) redirected to 0x4c25460 (index)
  --30287-- REDIR: 0x4016120 (strcmp) redirected to 0x4c25e30 (strcmp)
  --30287-- Reading syms from /lib/libm-2.11.2.so (0x4e29000)
  --30287--   Considering /lib/libm-2.11.2.so ..
  --30287--   .. CRC mismatch (computed dd5c85df wanted ccd85fcf)
  --30287--   Considering /usr/lib/debug/lib/libm-2.11.2.so ..
  --30287--   .. CRC is valid
  --30287-- Reading syms from /lib/libc-2.11.2.so (0x50ab000)
  --30287--   Considering /lib/libc-2.11.2.so ..
  --30287--   .. CRC mismatch (computed 7d8e8f4f wanted 9b015f2c)
  --30287--   Considering /usr/lib/debug/lib/libc-2.11.2.so ..
  --30287--   .. CRC is valid
  --30287-- REDIR: 0x5128600 (__GI_strrchr) redirected to 0x4c25280 (__GI_strrchr)
  --30287-- REDIR: 0x51218c0 (malloc) redirected to 0x4c24466 (malloc)
  --30287-- REDIR: 0x5128d00 (memchr) redirected to 0x4c25ed0 (memchr)
  --30287-- REDIR: 0x512a750 (memcpy) redirected to 0x4c25f00 (memcpy)
  --30287-- REDIR: 0x5126b10 (strlen) redirected to 0x4a205ac (_vgnU_ifunc_wrapper)
   ==30287== WARNING: new redirection conflicts with existing -- ignoring it
  --30287--     new: 0x05126b40 (__GI_strlen         ) R-> 0x04c257f0 strlen
  --30287-- REDIR: 0x5126b40 (__GI_strlen) redirected to 0x4c25810 (__GI_strlen)
  --30287-- REDIR: 0x512baf0 (__GI___rawmemchr) redirected to 0x4c26ba0 (__GI___rawmemchr)
  --30287-- REDIR: 0x51217e0 (free) redirected to 0x4c24076 (free)
   Following are the keys and their corresponding value present
  --30287-- REDIR: 0x512bb40 (strchrnul) redirected to 0x4c26b50 (strchrnul)

3 个答案:

答案 0 :(得分:3)

您可以在/usr/lib/valgrind/default.supp

中查看/修改已删除的错误

答案 1 :(得分:2)

被抑制的错误只是系统特定的错误,您的库已知问题。因此,他们不是另一个系统的可移植性问题的正确嫌疑人。

答案 2 :(得分:2)

在x86主机上,valgrind输出这样的行: For counts of detected and suppressed errors, rerun with: -v 所以像这样运行你的编程:valgrind -v ./myprog