0

这是我第一次看到 valgrind 日志,这个日志是由其他用户提供的(我无法运行 valgrind,因为它不支持 stlinux (sh4)

为了了解如何使用 valgrind 日志修复内存泄漏,如果有专家,将不胜感激,甚至选择 bellow 的 valgrind 错误日志中的一行(并告诉我们,他打算修复的 valgrind 错误行并发布他们的修复(源代码补丁)

然后,将学习如何从 valgrind 日志中修复内存泄漏,然后我将自己修复(我只需要一个示例修复)

这是应用程序 trac 浏览器(源代码): http ://www.streamboard.tv/oscam/browser/trunk/?rev=5375

如果有专家可以查看这些日志(我真的需要帮助),将不胜感激,这里有 4 个 valgrind 日志:

http://www.4shared.com/office/04seUumN/valgrind_2.html _ _

http://www.4shared.com/office/WYmfxICb/valgrindlog.html

http://www.4shared.com/office/WGwlKeUK/valgrind.html

http://www.4shared.com/office/mkX4FAzd/valgrind_1.html _ _

PS:

  1. 由于我自己无法运行 valgrind,请选择内存损失最大的内存泄漏(泄漏),然后,我可以用我的眼睛监控这些改进(top 命令,ps -aux)

  2. 我对修复内存泄漏的关注主要限于这些模块(对我来说,优先级(重要性)在于它们的编号顺序(我的意思是,使用 module-datastruct-list.c 修复内存泄漏对我来说是重中之重,. ...)

    • 模块数据结构列表.c
    • oscam-garbage.c
    • oscam.c
    • 模块-cccam.c
    • 模块-dvbapi.c

提前致谢

4

1 回答 1

2

I used Valgrind a long time ago so I don't remember well how to use it, but I know it is fairly easy. Valgrind logs show every memory leak of the program, due to your code, but also due to code you call from libraries. For every leak, the function call stack is displayed, like this :

==5313== Invalid write of size 4
==5313==    at 0x8048A27: test_2() (valgrind-tests.cc:37)
==5313==    by 0x8048CDF: main (valgrind-tests.cc:134)
==5313==    by 0x215BBE: __libc_start_main (in /lib/libc-2.3.2.so)
==5313==    by 0x8048910: (within /home/newren/examples/valgrind-tests)
==5313==    Address 0x1B3E024 is 0 bytes inside a block of size 4 free'd
==5313==    at 0x5419C5: __builtin_delete (vg_replace_malloc.c:244)
==5313==    by 0x5419E3: operator delete(void*) (vg_replace_malloc.c:253)
==5313==    by 0x8048A20: test_2() (valgrind-tests.cc:36)
==5313==    by 0x8048CDF: main (valgrind-tests.cc:134)
==5313==    by 0x215BBE: __libc_start_main (in /lib/libc-2.3.2.so)
==5313==    by 0x8048910: (within /home/newren/examples/valgrind-tests)

This means you try to write 4 bytes in memory, but you don't have access to theses bytes. This issue is located at line 37 of "valgrind-tests.cc" in this example.

The main problem of valgrind is that, as I said earlier, it displays memory leaks or memory warnings (like forgotten pointers) from libraries you use. To clean your logs, you can write valgrind rule files called "suppression files".

More informations here and here.

于 2012-10-17T12:39:44.430 回答