Valgrind has a weird hack where it invokes a glibc function called
__libc_freeres on exit. See:
http://valgrind.org/docs/manual/faq.html#faq.exit_errors
This is intended to free up memory that glibc won't normally free,
since glibc doesn't free everything on exit for efficiency reasons.
We have to add suppressions for those kinds of leaks.
More importantly, valgrind runs __libc_freeres even if the process
calls _exit, resulting in this bug:
https://bugs.kde.org/show_bug.cgi?id=361810
(either a bug in valgrind, or in glibc, or in both, depending on your
point of view). In any case we don't want this behaviour, so disable
it.
---
m4/guestfs_progs.m4 | 2 +-
valgrind-suppressions | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/m4/guestfs_progs.m4 b/m4/guestfs_progs.m4
index 070fd6d..1ac2081 100644
--- a/m4/guestfs_progs.m4
+++ b/m4/guestfs_progs.m4
@@ -125,7 +125,7 @@ dnl Check for valgrind
AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
AS_IF([test "x$VALGRIND" != "xno"],[
# Substitute the whole valgrind command.
- VG='$(VALGRIND) --vgdb=no
--log-file=$(abs_top_builddir)/tmp/valgrind-%q{T}-%p.log --leak-check=full
--error-exitcode=119 --suppressions=$(abs_top_srcdir)/valgrind-suppressions
--trace-children=no --child-silent-after-fork=yes'
+ VG='$(VALGRIND) --vgdb=no
--log-file=$(abs_top_builddir)/tmp/valgrind-%q{T}-%p.log --leak-check=full
--error-exitcode=119 --suppressions=$(abs_top_srcdir)/valgrind-suppressions
--trace-children=no --child-silent-after-fork=yes --run-libc-freeres=no'
],[
# No valgrind, so substitute VG with something that will break.
VG=VALGRIND_IS_NOT_INSTALLED
diff --git a/valgrind-suppressions b/valgrind-suppressions
index 5ed4d2d..93b0402 100644
--- a/valgrind-suppressions
+++ b/valgrind-suppressions
@@ -188,6 +188,17 @@
fun:expand_dynamic_string_token
}
+# Not a real leak - glibc doesn't bother to free thread
+# data (TLS in this case).
+{
+ glibc_leak_1
+ Memcheck:Leak
+ fun:calloc
+ fun:allocate_dtv
+}
+
+
+
# libvirt calls gnutls_global_init but doesn't call the
# corresponding gnutls_global_deinit function because of
# thread-safety issues (in GnuTLS).
--
2.7.4