Blame helgrind-and-drd-suppression-libc-and-libpthread.patch

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