valgrind Error: Conditional jump or move depends on uninitialised value(s)

╄→гoц情女王★ 提交于 2020-01-14 10:43:14

问题


I have one program:

#include <stdio.h>

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

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

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.

What does it mean?

How can they harm my program?

How can I remove them?


回答1:


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

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.




回答2:


Though this is coming from system libraries and has nothing to do with your code (and looks harmless) ensure that you have correct .supp files in /usr/lib/valgrind directory. Corresponding to your glibc version, there would be a section which suppresses such error messages:

#-------- glibc 2.3.4/ Fedora Core 3
{
   dl_relocate_object
   Memcheck:Cond
   fun:_dl_relocate_object
}

Maybe you want to check your valgrind's installation.



来源:https://stackoverflow.com/questions/7791012/valgrind-error-conditional-jump-or-move-depends-on-uninitialised-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!