C valgrind错误:条件跳转或移动取决于未初始化的值
我有一个计划:C valgrind错误:条件跳转或移动取决于未初始化的值,c,linux,memory,valgrind,C,Linux,Memory,Valgrind,我有一个计划: #包括 int调用(){ int x=25; ++x; 返回x; } int main(){ INTP; p=调用(); printf(“%d”,p); 返回0; } 当我用-g选项编译程序并用valgrind运行它时,它显示: ==15469== 1 errors in context 1 of 8: ==15469== Conditional jump or move depends on uninitialised value(s) ==15469== at 0
#包括
int调用(){
int x=25;
++x;
返回x;
}
int main(){
INTP;
p=调用();
printf(“%d”,p);
返回0;
}
当我用-g
选项编译程序并用valgrind运行它时,它显示:
==15469== 1 errors in context 1 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469== at 0x546F83: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469== by 0x53E6CC: dl_main (in /lib/ld-2.12.90.so)
==15469== by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469== by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469== by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469==
==15469==
==15469== 1 errors in context 2 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469== at 0x546E01: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469== by 0x53E6CC: dl_main (in /lib/ld-2.12.90.so)
==15469== by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469== by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469== by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469==
==15469==
==15469== 1 errors in context 3 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469== at 0x546DF9: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469== by 0x53E6CC: dl_main (in /lib/ld-2.12.90.so)
==15469== by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469== by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469== by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469==
==15469==
==15469== 1 errors in context 4 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469== at 0x546E01: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469== by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469== by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469== by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469== by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469==
==15469==
==15469== 1 errors in context 5 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469== at 0x546DF9: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469== by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469== by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469== by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469== by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469==
==15469==
==15469== 2 errors in context 6 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469== at 0x546F83: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469== by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469== by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469== by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469== by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469==
==15469==
==15469== 2 errors in context 7 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469== at 0x547871: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469== by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469== by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469== by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469== by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469==
==15469==
==15469== 4 errors in context 8 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469== at 0x546F4D: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469== by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469== by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469== by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469== by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469==
==15469== ERROR SUMMARY: 13 errors from 8 contexts (suppressed: 0 from 0)
我不知道为什么会出现这个错误
这是什么意思
他们怎么能破坏我的程序
如何删除它们?这些不是来自您的代码,而是来自
/lib/ld-*。因此是动态库加载器
这是一段被广泛使用的代码,我很难想象它有如此明显的bug,所以我认为valgrind给了你误报。您可能可以安全地忽略它们。尽管这是来自系统库,与您的代码无关(看起来无害),但请确保您在/usr/lib/valgrind
目录中有正确的.supp文件。与您的glibc版本相对应,将有一个部分用于抑制此类错误消息:
#-------- glibc 2.3.4/ Fedora Core 3
{
dl_relocate_object
Memcheck:Cond
fun:_dl_relocate_object
}
也许你想检查一下valgrind的安装 如果它是从自己的代码中犯下的,那么这个错误意味着什么?那么它会损害我的代码吗?是的,那么它可能是一个bug的迹象。例如,这将触发它:inti;如果(i)printf(“Hello world\n”)代码>。这是未定义的行为,因为i
尚未初始化。