From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id B3030385783F; Tue, 16 May 2023 09:05:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3030385783F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684227939; bh=m+t2ASEG+ntri/nhHZbThA4wgYWgRqlCJPvl+K2Ncss=; h=From:To:Subject:Date:From; b=BCT5bldqBw63cY5vG8dSiIGFO/tikX0qyROuFUyFvwkGHlhMLqvnbHj3Nwu5lzVVk 8V5LDFWsv0fEdF7U6xRhXmfWxIsxCS4SK23yv3QJEIppQx1O/ahy6vi99YvbCbLe41 HDQP6Wff61/C/jDRtJjdpF/f1IG41rJYCpMymE8A= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-905] libstdc++: Do not use pthread_mutex_clocklock with ThreadSanitizer X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 45efdda3ff6c92f948881298031779f81aad0886 X-Git-Newrev: 3b7cb33033fbe6af6c1c4ef014f7353479d1dd6b Message-Id: <20230516090539.B3030385783F@sourceware.org> Date: Tue, 16 May 2023 09:05:39 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3b7cb33033fbe6af6c1c4ef014f7353479d1dd6b commit r14-905-g3b7cb33033fbe6af6c1c4ef014f7353479d1dd6b Author: Jonathan Wakely Date: Tue May 9 09:30:48 2023 +0100 libstdc++: Do not use pthread_mutex_clocklock with ThreadSanitizer 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 Reviewed-by: Mike Crowe libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK): Define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK in terms of _GLIBCXX_TSAN. * configure: Regenerate. Diff: --- 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 .]) + AC_DEFINE(_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK, (_GLIBCXX_TSAN==0), [Define if pthread_mutex_clocklock is available in .]) 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