gpt4 book ai didi

c - Valgrind 在每个程序上报告 "Conditional jump or move depends on uninitialised value(s)"

转载 作者:行者123 更新时间:2023-12-01 23:56:01 27 4
gpt4 key购买 nike

我正在学习“硬道学习 C”并使用 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;
}

最佳答案

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

关于c - Valgrind 在每个程序上报告 "Conditional jump or move depends on uninitialised value(s)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23663008/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com