valgrind误会公会

时间:2014-11-10 21:31:24

标签: c linux valgrind

我正在关注cLearnTheHardWay并且我刚刚使用了valgrind工具,但我混淆了如何阅读它以便我可以修复与内存泄漏相关的错误,如果任何人可以解释我这几行怎么读它可能有助于制作更好

ex.c     #include

/* Warning: This program is wrong on purpose. */

int main()
{
int age=10;
int height;

printf("I am %d years old.\n");
printf("I am %d inches tall.\n", height);

return 0;
}

I am -16777528 years old.
==15826== Conditional jump or move depends on uninitialised value(s)
==15826==    at 0x4E8047E: vfprintf (vfprintf.c:1660)
==15826==    by 0x4E8A388: printf (printf.c:33)
==15826==    by 0x40055E: main (ex4.c:11)
==15826== 
==15826== Use of uninitialised value of size 8
==15826==    at 0x4E7F93B: _itoa_word (_itoa.c:179)
==15826==    by 0x4E835E6: vfprintf (vfprintf.c:1660)
==15826==    by 0x4E8A388: printf (printf.c:33)
==15826==    by 0x40055E: main (ex4.c:11)
==15826== 
==15826== Conditional jump or move depends on uninitialised value(s)
==15826==    at 0x4E7F945: _itoa_word (_itoa.c:179)
==15826==    by 0x4E835E6: vfprintf (vfprintf.c:1660)
==15826==    by 0x4E8A388: printf (printf.c:33)
==15826==    by 0x40055E: main (ex4.c:11)
==15826== 

1 个答案:

答案 0 :(得分:0)

它表示您的程序正在使用未初始化的数据,并且负责的函数调用位于ex4.c文件的第11行。检查代码应该显示问题的原因(你声明并使用一些变量而不给它赋值)。将编译器警告级别提高到最大值也应该确定问题。