本文介绍了与-static链接时出现Valgrind错误-为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试驱动程序链接到我编写的库。该库使用自动工具,因此会同时生成一个存档(.a文件)和一个动态库(.so)。



当我将驱动程序与 g ++ -static链接时,可能是链接到.a的valgrind反复点亮,抱怨有条件的跳跃或移动取决于未初始化的值。第一次失败发生在main之前__pthread_initialize_minimal中。 >

有人知道为什么吗? valgrind不能只与-static一起使用吗?



更新:我什至无法发布简化版本的驱动程序,因为它链接到一个我无法缩减的非常大的库,但我注意到所有程序中最简单的

  int main()
{
返回0;
}

与-static链接并从valgrind运行时给出错误:

  == 15449 ==使用大小为8的未初始化值
== 15449 == at 0x40B0F3:exit(in / home / jdgordo / src / t)

我应该包括我在64位Redhat上运行5.5。

解决方案

是的。问题不在Valgrind中,而是在glibc中,这不是Valgrind干净的。 glibc开发人员拒绝修复这些问题(因为这些问题属于无关紧要性质,并且修复(花费了一些)周期)。



何时您可以动态链接,这些错误来自 libc.so.6 ,并且可以很容易地被抑制,这是Valgrind的默认设置。



但是,当您静态链接时,这些错误来自您的可执行文件(现在包括来自 libc.a 的代码),因此默认的Valgrind抑制不会



您可以编写新的抑制项(请参见Valgrind -gen-suppressions = yes )。



或者您可以安装并使用。


I have a test driver linked to a library I wrote. The library uses autotools so it produces both an archive (.a file) and a dynamic library (.so).

When I link my driver with 'g++ -static', presumably linking to the .a, valgrind lights up complaining repeatedly 'Conditional jump or move depends on uninitialised value(s)'. The first failure occurs before main in __pthread_initialize_minimal.

When I link without -static, presumably linking with the .so, I don't get any valgrind complaints.

Does anyone know why? Does valgrind just not work with -static?

UPDATE: I can't post even a pared down version of my driver because it links to a very large library that I couldn't possible pare down, but I notice that simplest of all programs

int main()
{
  return 0;
}

gives an error when linked with -static and run from valgrind:

==15449== Use of uninitialised value of size 8
==15449==    at 0x40B0F3: exit (in /home/jdgordo/src/t)

I should have included that I'm running on 64-bit Redhat 5.5.

解决方案

It does. The problem is not in Valgrind, it's in glibc, which is not Valgrind clean. The glibc developers refused to fix these problems (because the problems are of a "don't care" nature, and fixing them costs (a few) cycles).

When you link dynamically, these errors come from libc.so.6, and can be easily suppressed, which is what Valgrind does by default.

But when you link statically, these errors come from your executable (which now includes code from libc.a), and so the default Valgrind suppressions don't suppress them.

You could write new suppressions (see Valgrind --gen-suppressions=yes documentation).

Or you could install and use glibc-audit.

这篇关于与-static链接时出现Valgrind错误-为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 02:50