From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 35B973858439 for ; Tue, 16 May 2023 09:05:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35B973858439 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684227958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8sI8xw2vBqAcyZqqcxUm2CDK2xGehcwb8qyVWbnj1SQ=; b=W7eOasQgudarh1NQ+QML9Cu59X56Lsr5puCdEFVC1QIV5vXToPGt6Fni5irtYZRLSeNhZe 6lcOV1kMbbeQokRYUfVNH4RTQoSQhlj8lN/GQrOVFtmFaZBAfmrjqu4yuqDt/nke+MGvjt +NrTcZbsoCltRMdgsfKqCGiyZQGyNLU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-mt1cPX63M6qu0xheEx2MVg-1; Tue, 16 May 2023 05:05:57 -0400 X-MC-Unique: mt1cPX63M6qu0xheEx2MVg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D74D23801F55; Tue, 16 May 2023 09:05:56 +0000 (UTC) Received: from localhost (unknown [10.42.28.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C9F063F8B; Tue, 16 May 2023 09:05:56 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: Thomas Rodgers , Mike Crowe Subject: [committed] libstdc++: Do not use pthread_mutex_clocklock with ThreadSanitizer Date: Tue, 16 May 2023 10:05:55 +0100 Message-Id: <20230516090555.1698108-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 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. --- 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 -- 2.40.1