From 5e16f12e5e812d8ed4e3e96f373d73c22c964148 Mon Sep 17 00:00:00 2001 From: Mark Wielaard 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