From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc: Thomas Rodgers <trodgers@redhat.com>, Mike Crowe <mac@mcrowe.com>
Subject: [committed] libstdc++: Do not use pthread_mutex_clocklock with ThreadSanitizer
Date: Tue, 16 May 2023 10:05:55 +0100 [thread overview]
Message-ID: <20230516090555.1698108-1-jwakely@redhat.com> (raw)
Tested powerpc64le-linux. Pushed to trunk.
-- >8 --
As noted in https://github.com/llvm/llvm-project/issues/62623 there are
no tsan interceptors for some of the new POSIX-1:202x APIs added by
https://austingroupbugs.net/view.php?id=1216 so tsan gives false
positive warnings for try_lock_for on timed mutexes.
Disable the uses of the new pthread_mutex_clocklock API when tsan is
active. This changes the semantics of the try_lock_for functions,
because it can change which clock is used for the wait. This means those
functions might be affected by system clock adjustments when tsan is
used, when they would not be affected otherwise.
Reviewed-by: Thomas Rodgers <trodgers@redhat.com>
Reviewed-by: Mike Crowe <mac@mcrowe.com>
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK): Define
_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK in terms of _GLIBCXX_TSAN.
* configure: Regenerate.
---
libstdc++-v3/acinclude.m4 | 2 +-
libstdc++-v3/configure | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 42a8e7a775e..0ce3b8b5b31 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -4314,7 +4314,7 @@ AC_DEFUN([GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK], [
[glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK=no])
])
if test $glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK = yes; then
- AC_DEFINE(_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK, 1, [Define if pthread_mutex_clocklock is available in <pthread.h>.])
+ AC_DEFINE(_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK, (_GLIBCXX_TSAN==0), [Define if pthread_mutex_clocklock is available in <pthread.h>.])
fi
CXXFLAGS="$ac_save_CXXFLAGS"
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index d4286b67a73..c1faebd54f2 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -21364,7 +21364,7 @@ fi
$as_echo "$glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK" >&6; }
if test $glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK = yes; then
-$as_echo "#define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK 1" >>confdefs.h
+$as_echo "#define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK (_GLIBCXX_TSAN==0)" >>confdefs.h
fi
--
2.40.1
reply other threads:[~2023-05-16 9:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230516090555.1698108-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=mac@mcrowe.com \
--cc=trodgers@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).