valgrind错误:条件跳转或移动取决于未初始化的值

问题描述 投票:4回答:2

我有一个程序:

#include <stdio.h>

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

int main(){ 
  int p; 
  p=call(); 
  printf("%d",p);
  return 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)

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

这是什么意思?

它们如何危害我的程序?

如何删除它们?

c linux memory valgrind
2个回答
4
投票

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

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


1
投票

尽管这来自系统库,并且与您的代码无关(并且看起来无害),请确保/usr/lib/valgrind目录中具有正确的.supp文件。对应于您的glibc版本,会有一个部分禁止显示此类错误消息:

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

也许您想检查valgrind的安装。

© www.soinside.com 2019 - 2024. All rights reserved.