3.17.0-7 Add helgrind-and-drd-suppression-libc-and-libpthread.patch

This commit is contained in:
Mark Wielaard 2021-07-17 20:43:29 +02:00
parent 3e84ebda23
commit 5a53fca2ab
3 changed files with 249 additions and 21 deletions

View File

@ -0,0 +1,241 @@
From 5e16f12e5e812d8ed4e3e96f373d73c22c964148 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 16 Jul 2021 15:47:08 -0400
Subject: [PATCH] Update helgrind and drd suppression libc and libpthread paths
in glibc 2.34
glibc 2.34 moved all pthread functions into the main libc library.
And it changed the (in memory) path of the main libc library to
libc.so.6 (before it was libc-2.xx.so).
This breaks various standard suppressions for helgrind and drd.
Fix this by doing a configure check for whether we are using glibc
2.34 by checking whether pthread_create is in libc instead of in
libpthread. If we are using glibc then define GLIBC_LIBC_PATH and
GLIBC_LIBPTHREAD_PATH variables that point to the (regexp) path
of the library that contains all libc functions and pthread functions
(which will be the same path for glibc 2.34+).
Rename glibc-2.34567-NPTL-helgrind.supp to glibc-2.X-helgrind.supp.in
and glibc-2.X-drd.supp to glibc-2.X-drd.supp.in and replace the
GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH at configure time.
The same could be done for the glibc-2.X.supp.in file, but hasn't
yet because it looks like most suppressions in that file are obsolete.
---
Makefile.am | 2 +-
configure.ac | 37 +++++++++++++++++--
glibc-2.X-drd.supp => glibc-2.X-drd.supp.in | 6 ++-
...elgrind.supp => glibc-2.X-helgrind.supp.in | 16 ++++----
4 files changed, 47 insertions(+), 14 deletions(-)
rename glibc-2.X-drd.supp => glibc-2.X-drd.supp.in (97%)
rename glibc-2.34567-NPTL-helgrind.supp => glibc-2.X-helgrind.supp.in (95%)
diff --git a/Makefile.am b/Makefile.am
index 66848afaa..f5935eb69 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,7 +41,7 @@ SUPP_FILES = \
glibc-2.2.supp glibc-2.3.supp glibc-2.4.supp glibc-2.5.supp \
glibc-2.6.supp glibc-2.7.supp glibc-2.X.supp.in \
xfree-3.supp xfree-4.supp \
- glibc-2.34567-NPTL-helgrind.supp \
+ glibc-2.X-helgrind.supp \
glibc-2.2-LinuxThreads-helgrind.supp \
glibc-2.X-drd.supp \
darwin9.supp darwin9-drd.supp \
diff --git a/configure.ac b/configure.ac
index 4582fb5d0..beb5bba79 100755
--- a/configure.ac
+++ b/configure.ac
@@ -1090,6 +1090,31 @@ if test x$GLIBC_VERSION = x; then
fi
fi
+# If this is glibc then figure out the generic (in file) libc.so and
+# libpthread.so file paths to use in suppressions. Before 2.34 libpthread
+# was a separate library, afterwards it was merged into libc.so and
+# the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
+# Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
+case ${GLIBC_VERSION} in
+2*)
+ AC_MSG_CHECKING([whether pthread_create needs libpthread])
+ AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
+ [
+ AC_MSG_RESULT([no])
+ GLIBC_LIBC_PATH="*/lib*/libc.so.6"
+ GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
+ ], [
+ AC_MSG_RESULT([yes])
+ GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
+ GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
+ ])
+ ;;
+*)
+ AC_MSG_CHECKING([not glibc...])
+ AC_MSG_RESULT([${GLIBC_VERSION}])
+ ;;
+esac
+
AC_MSG_CHECKING([the glibc version])
case "${GLIBC_VERSION}" in
@@ -1102,13 +1127,13 @@ case "${GLIBC_VERSION}" in
2.[[3-6]])
AC_MSG_RESULT(${GLIBC_VERSION} family)
DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
- DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
+ DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
;;
2.[[7-9]])
AC_MSG_RESULT(${GLIBC_VERSION} family)
DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
- DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
+ DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
;;
2.10|2.11)
@@ -1116,7 +1141,7 @@ case "${GLIBC_VERSION}" in
AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
[Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
- DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
+ DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
;;
2.*)
@@ -1126,7 +1151,7 @@ case "${GLIBC_VERSION}" in
AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
[Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
- DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
+ DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
;;
darwin)
@@ -1157,6 +1182,8 @@ case "${GLIBC_VERSION}" in
esac
AC_SUBST(GLIBC_VERSION)
+AC_SUBST(GLIBC_LIBC_PATH)
+AC_SUBST(GLIBC_LIBPTHREAD_PATH)
if test "$VGCONF_OS" != "solaris"; then
@@ -4928,6 +4955,8 @@ AC_CONFIG_FILES([
valgrind.spec
valgrind.pc
glibc-2.X.supp
+ glibc-2.X-helgrind.supp
+ glibc-2.X-drd.supp
docs/Makefile
tests/Makefile
tests/vg_regtest
diff --git a/glibc-2.X-drd.supp b/glibc-2.X-drd.supp.in
similarity index 97%
rename from glibc-2.X-drd.supp
rename to glibc-2.X-drd.supp.in
index cee5f22fb..2c880051a 100644
--- a/glibc-2.X-drd.supp
+++ b/glibc-2.X-drd.supp.in
@@ -1,3 +1,5 @@
+# IMPORTANT: DO NOT EDIT glibc-2.X-drd.supp, as it is as a generated
+# file. Instead edit glibc-2.X-drd.supp.in.
#
# Suppression patterns for ld, the dynamic loader.
#
@@ -6,7 +8,7 @@
{
drd-ld
drd:ConflictingAccess
- obj:*/lib*/ld-*.so
+ obj:*/lib*/ld-*.so*
}
#
@@ -22,7 +24,7 @@
{
drd-libc-stdio
drd:ConflictingAccess
- obj:*/lib*/libc-*
+ obj:@GLIBC_LIBC_PATH@
}
{
drd-libc-thread-cancellation-test
diff --git a/glibc-2.34567-NPTL-helgrind.supp b/glibc-2.X-helgrind.supp.in
similarity index 95%
rename from glibc-2.34567-NPTL-helgrind.supp
rename to glibc-2.X-helgrind.supp.in
index 7ebd2c4b4..cecf3ceab 100644
--- a/glibc-2.34567-NPTL-helgrind.supp
+++ b/glibc-2.X-helgrind.supp.in
@@ -1,3 +1,5 @@
+# IMPORTANT: DO NOT EDIT glibc-2.X-helgrind.supp, as it is as a generated
+# file. Instead edit glibc-2.X-helgrind.supp.in.
# FIXME 22 Jan 09: helgrind-glibc2X-005 overlaps with a lot of
# other stuff. They should be removed.
@@ -41,7 +43,7 @@
{
helgrind-glibc2X-004
Helgrind:Race
- obj:*/lib*/libc-2.*so*
+ obj:@GLIBC_LIBC_PATH@
}
{
@@ -49,13 +51,13 @@
Helgrind:Race
fun:__GI_mempcpy
fun:_IO_*xsputn*
- obj:*/lib*/libc-2.*so*
+ obj:@GLIBC_LIBC_PATH@
}
{
helgrind-glibc2X-005
Helgrind:Race
- obj:*/lib*/libpthread-2.*so*
+ obj:@GLIBC_LIBPTHREAD_PATH@
}
# helgrind-glibc2X-006 was merged into helgrind-glibc2X-005
@@ -90,14 +92,14 @@
{
helgrind-glibc2X-101
Helgrind:Race
- obj:*/lib*/libpthread-2.*so*
+ obj:@GLIBC_LIBPTHREAD_PATH@
fun:pthread_*
}
{
helgrind-glibc2X-102
Helgrind:Race
fun:mythread_wrapper
- obj:*/lib*/libpthread-2.*so*
+ obj:@GLIBC_LIBPTHREAD_PATH@
}
{
helgrind-glibc2X-103
@@ -122,7 +124,7 @@
{
helgrind-glibc2X-107
Helgrind:Race
- obj:*/lib*/libpthread-2.*so*
+ obj:@GLIBC_LIBPTHREAD_PATH@
fun:sem_*
}
{
@@ -138,7 +140,7 @@
{
helgrind-glibc2X-110
Helgrind:Race
- obj:*/lib*/libc-2.*so*
+ obj:@GLIBC_LIBC_PATH@
fun:pthread_*
}
{
--
2.27.0

View File

@ -1,15 +0,0 @@
--- valgrind/glibc-2.34567-NPTL-helgrind.supp.jj 2009-08-19 15:37:48.000000000 +0200
+++ valgrind/glibc-2.34567-NPTL-helgrind.supp 2009-10-21 16:46:31.000000000 +0200
@@ -88,6 +88,12 @@
obj:*/lib*/libpthread-2.*so*
}
{
+ helgrind-glibc2X-102a
+ Helgrind:Race
+ fun:mythread_wrapper
+ obj:*vgpreload_helgrind*.so
+}
+{
helgrind-glibc2X-103
Helgrind:Race
fun:pthread_cond_*@@GLIBC_2.*

View File

@ -3,7 +3,7 @@
Summary: Tool for finding memory management bugs in programs Summary: Tool for finding memory management bugs in programs
Name: %{?scl_prefix}valgrind Name: %{?scl_prefix}valgrind
Version: 3.17.0 Version: 3.17.0
Release: 6%{?dist} Release: 7%{?dist}
Epoch: 1 Epoch: 1
License: GPLv2+ License: GPLv2+
URL: http://www.valgrind.org/ URL: http://www.valgrind.org/
@ -76,9 +76,6 @@ Source0: ftp://sourceware.org/pub/valgrind/valgrind-%{version}.tar.bz2
# Needs investigation and pushing upstream # Needs investigation and pushing upstream
Patch1: valgrind-3.9.0-cachegrind-improvements.patch Patch1: valgrind-3.9.0-cachegrind-improvements.patch
# KDE#211352 - helgrind races in helgrind's own mythread_wrapper
Patch2: valgrind-3.9.0-helgrind-race-supp.patch
# Make ld.so supressions slightly less specific. # Make ld.so supressions slightly less specific.
Patch3: valgrind-3.9.0-ldso-supp.patch Patch3: valgrind-3.9.0-ldso-supp.patch
@ -153,6 +150,9 @@ Patch13: valgrind-3.17.0-s390-z13-vec-fix.patch
# gdbserver_tests: update filters for newer glibc/gdb # gdbserver_tests: update filters for newer glibc/gdb
Patch14: gdbserver_tests-update-filters-for-newer-glibc-gdb.patch Patch14: gdbserver_tests-update-filters-for-newer-glibc-gdb.patch
# KDE#439590 glibc-2.34 breaks suppressions against obj:*/lib*/libc-2.*so*
Patch15: helgrind-and-drd-suppression-libc-and-libpthread.patch
BuildRequires: make BuildRequires: make
BuildRequires: glibc-devel BuildRequires: glibc-devel
@ -285,7 +285,6 @@ Valgrind User Manual for details.
%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version} %setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}
%patch1 -p1 %patch1 -p1
%patch2 -p1
%patch3 -p1 %patch3 -p1
# Old rhel gcc doesn't have -fstack-protector-strong. # Old rhel gcc doesn't have -fstack-protector-strong.
@ -307,6 +306,7 @@ touch memcheck/tests/s390x/vistr.stdout.exp
%patch13 -p1 %patch13 -p1
%patch14 -p1 %patch14 -p1
%patch15 -p1
%build %build
# LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto
@ -532,8 +532,10 @@ fi
%endif %endif
%changelog %changelog
* Sat Jul 17 2021 Mark Wielaard <mjw@fedoraproject.org> * Sat Jul 17 2021 Mark Wielaard <mjw@fedoraproject.org> - 3.17.0-7
- Add gdbserver_tests-update-filters-for-newer-glibc-gdb.patch - Add gdbserver_tests-update-filters-for-newer-glibc-gdb.patch
- Add helgrind-and-drd-suppression-libc-and-libpthread.patch
- Remove valgrind-3.9.0-helgrind-race-supp.patch
* Fri Jul 9 2021 Mark Wielaard <mjw@fedoraproject.org> - 3.17.0-6 * Fri Jul 9 2021 Mark Wielaard <mjw@fedoraproject.org> - 3.17.0-6
- Update to include fixed CI gating tests. - Update to include fixed CI gating tests.