c - 解决由 valgrind 检查的内存问题

标签 c linux valgrind

我有一个关于 valgrind 的问题;我不知道为什么当我用 valgrind 检查我在 C 中开发的程序时,它无法在发现问题的地方显示函数名称(它显示“???”),但这个问题并不适用于它检测到的所有错误

==9803== ERROR SUMMARY: 24 errors from 6 contexts (suppressed: 0 from 0)
==9803== 
==9803== 1 errors in context 1 of 6:
==9803== Conditional jump or move depends on uninitialised value(s)
==9803==    at 0x40F7EC6: ???
==9803== 
==9803== 1 errors in context 2 of 6:
==9803== Conditional jump or move depends on uninitialised value(s)
==9803==    at 0x40F86F8: ???
==9803== 
==9803== 1 errors in context 3 of 6:
==9803== Conditional jump or move depends on uninitialised value(s)
==9803==    at 0x40F8166: ???
==9803== 
==9803== 1 errors in context 4 of 6:
==9803== Conditional jump or move depends on uninitialised value(s)
==9803==    at 0x40F805E: ???
==9803==

您有使用 valgrind 显示函数名称的解决方案吗?

提前致谢

最佳答案

大概这些错误发生在您没有调试符号的库中。 很容易确认:只需在应用程序运行时查看/proc/pidof my-binary/maps。

08048000-08052000 r-xp 00000000 fe:00 42546         /bin/cat
08052000-08053000 rw-p 0000a000 fe:00 42546         /bin/cat
097fb000-0981c000 rw-p 00000000 00:00 0             [heap]
f73bc000-f75ac000 r--p 00000000 fe:02 281727        /usr/lib/locale/locale-archive
f75ac000-f75ad000 rw-p 00000000 00:00 0 
f75ad000-f76ed000 r-xp 00000000 fe:00 18416         /lib/i686/cmov/libc-2.11.2.so
f76ed000-f76ef000 r--p 0013f000 fe:00 18416         /lib/i686/cmov/libc-2.11.2.so
f76ef000-f76f0000 rw-p 00141000 fe:00 18416         /lib/i686/cmov/libc-2.11.2.so
f76f0000-f76f3000 rw-p 00000000 00:00 0 
f7705000-f7707000 rw-p 00000000 00:00 0 
f7707000-f7708000 r-xp 00000000 00:00 0             [vdso]
f7708000-f7723000 r-xp 00000000 fe:00 19087         /lib/ld-2.11.2.so
f7723000-f7724000 r--p 0001a000 fe:00 19087         /lib/ld-2.11.2.so
f7724000-f7725000 rw-p 0001b000 fe:00 19087         /lib/ld-2.11.2.so
ffb6e000-ffb83000 rw-p 00000000 00:00 0             

这清楚地显示了每个共享库的代码段(标记为 r-xp)的地址。只需找到与您看到的地址匹配的范围,您至少会知道哪个图书馆负责。

关于c - 解决由 valgrind 检查的内存问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10348101/

相关文章:

c - 如何使用 winapi c 创建 Sprite 动画?

php - 同时执行多个PHP脚本

python - 如何提交调用我的 python 脚本的 SGE 作业

c - malloc.c :3074 + Valgrind output

c - realloc 不为下一个结构分配内存

c - 将两个有序链表合并为一个有序链表

c - 蓝牙与C的通信

linux - 如何从文件中删除重复的 header (Linux 中第一次出现除外)

c - valgrind 如何计算我的示例内存泄漏?

c++ - 我能否将 "force"Cachegrind 分析成一个操作(或行)?