Valgrind在每个程序中报告“条件跳转或移动取决于未初始化的值”

时间:2014-05-14 19:03:29

标签: c debugging valgrind

我正在通过“学习C the Hardway”并使用valgrind来调试我的程序,但它一直给我同样的错误,即使是我知道的事实是正确的程序。我在VMware虚拟机上运行ubuntu,我认为这可能是问题,但在使用相同设置的另一台Windows计算机上运行正常。我最初根据书中的sratch构建了valgrind,但删除了它并使用sudo-apt get install来查看它是否有所作为但仍然是同样的错误。

这是一个简单的hello world程序的错误,我在运行的每个C程序上得到完全相同的结果。

bizarro@ubuntu:~/Dropbox/Programming/C/TheHardWay/Exercises$ valgrind ./ex1
==8625== Memcheck, a memory error detector
==8625== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==8625== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==8625== Command: ./ex1
==8625== 
==8625== Conditional jump or move depends on uninitialised value(s)
==8625==    at 0x4019B04: index (strchr.S:77)
==8625==    by 0x4007DED: expand_dynamic_string_token (dl-load.c:425)
==8625==    by 0x4008D71: _dl_map_object (dl-load.c:2538)
==8625==    by 0x40014BD: map_doit (rtld.c:627)
==8625==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==8625==    by 0x4000B2E: do_preload (rtld.c:816)
==8625==    by 0x400446C: dl_main (rtld.c:1633)
==8625==    by 0x4017564: _dl_sysdep_start (dl-sysdep.c:249)
==8625==    by 0x4004CF7: _dl_start (rtld.c:332)
==8625==    by 0x40012D7: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)
==8625== 
Hello world.
This is a the print function
It prints things and needs a semi colon at the end
Which im not used to. Python has made me sloppy  
I miss Python already
==8625== 
==8625== HEAP SUMMARY:
==8625==     in use at exit: 0 bytes in 0 blocks
==8625==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==8625== 
==8625== All heap blocks were freed -- no leaks are possible
==8625== 
==8625== For counts of detected and suppressed errors, rerun with: -v
==8625== Use --track-origins=yes to see where uninitialised values come from
==8625== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

编辑*

这是代码,但就像我说的那样,这个消息独立于代码。

#include <stdio.h>

int main(int argc, char *argv[])
{
    puts("Hello world.");
    puts("This is a the print function");
    puts("It prints things and needs a semi colon at the end");
    puts("Which im not used to. Python has made me sloppy");
    puts("I miss Python already");

    return 0;
}

1 个答案:

答案 0 :(得分:3)

看起来Valgrind正在识别C运行时中的潜在问题。这不是您需要担心的事情,因此我建议您create a suppressions file忽略此特定警告。