本文介绍了valgrind错误:条件跳转或移动取决于未初始化的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序:

#include <stdio.h>

int  call(){ 
  int x=25; 
  ++x; 
  return x; 
} 

int main(){ 
  int p; 
  p=call(); 
  printf("%d",p);
  return 0;
} 

当我使用-g选项编译程序并使用valgrind运行它时,它显示:

When I compile the program with -g option and run it with valgrind it shows:

==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)

我不知道为什么会收到此错误.

I don't know why I am getting this error.

这是什么意思?

它们如何危害我的程序?

How can they harm my program?

如何删除它们?

推荐答案

这些不是来自您的代码,而是来自动态库加载器/lib/ld-*.so.

These are not from your code, but from /lib/ld-*.so which is the dynamic library loader.

这是一段使用广泛的代码,我几乎无法想象它有这么明显的错误,因此我认为valgrind会给您带来误报.您可能可以放心地忽略它们.

This is such a widely used piece of code that I can hardly imagine that it has such an obvious bug, so I think valgrind is giving you false positives. You can probably safely ignore them.

这篇关于valgrind错误:条件跳转或移动取决于未初始化的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 00:37