Valgrind errors when linked with -static — Why?

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.

Leave a Comment