Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
292 views
Welcome To Ask or Share your Answers For Others

1 Answer

Does valgrind just not work with -static?

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...