From patchwork Tue May 16 09:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 94548 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp281314vqo; Tue, 16 May 2023 02:06:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5s7mqtj7K4GoBRFvXnsV8NI0QQk4bdrsVqUAvlLpsG0D/pyv4PHDwtNJEZcvdysbrHHbhY X-Received: by 2002:a17:907:6e04:b0:96a:6c1:20a4 with SMTP id sd4-20020a1709076e0400b0096a06c120a4mr22697139ejc.56.1684228012766; Tue, 16 May 2023 02:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684228012; cv=none; d=google.com; s=arc-20160816; b=Blh5wpcrAWpu3/I9ZTrg8B7hZTiLAVnNpDxZqySq7YatoID/XUuH2mM+Pr+WjFYl6i V7tpTDILtgKN9SpePgKqo8ut4aDLSMd2q/K2aQxaXCCHEEDGjDXHuQ+QPAK6BjoZbbFl UAm8R58um8Rk2oSfyW0thPiSJRpvfIlsyQhqGfq25taD0nqInRhWa7z2RLPFIM/ltVe6 wySeUl/XsT80BPEBg7t3MvOqQUbhbbPj4h1nIytRb5ffF9t0ppgcfrsSZIPjR8pYvw5X p+3ItINwqqloOE+fZzEcH5QhcU8bnacdvjSRxUtSlKvKCyjbh8DiTrfj7MQ4PPP6uYY5 0Ucw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=8sI8xw2vBqAcyZqqcxUm2CDK2xGehcwb8qyVWbnj1SQ=; b=pZm278e1EiTAeUnkSU1sx1vQXQ9IREYHk4xkPH8kcrYvJOq7HlpEs6jETtzfj39Hmj tvwunXyOHXd78eFBUtp4kj9NbiR23MtVn3DjxeRTaE+Kjh4iXXyBXRvdvTTdP7i1oGOS fDo7shob5bDL5fN5BEH9YwWf0lccKqtTF60zjDgHpUGcxmlNWb5JpHB1Y8J7jwB+L+aU ELf7F5bZHVWaTnbsE/iTLdnS+CPhtSombSPLzgoHon7sUkUzrXY8IsVScajiuHbskVOU sGi6F0XQ9clAEEDBXdmww+g58jimxB6Xz47dKx7MMWEH9c9+vMf+IOvojyeUW0vXiNcg NbPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Uc29t2v0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p8-20020a1709061b4800b00965ccaed66fsi13857627ejg.1052.2023.05.16.02.06.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 02:06:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Uc29t2v0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F1F33857350 for ; Tue, 16 May 2023 09:06:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F1F33857350 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684228011; bh=8sI8xw2vBqAcyZqqcxUm2CDK2xGehcwb8qyVWbnj1SQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Uc29t2v05wboXB7Y4aO5Cj/UNOpP7N/mpEgbxOlpwBknfW/SZ92lnFZDArPiHb+hl WBwDjkAMviMNSFBTMQ1k8JA2uKRt/yGLMaXjEIekAC4mb5jPmVJUnabtRPSWAfCIQH uxythPk9Fz3a1GYEnUATES7usC2p4HziixYLgZus= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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) 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766041072630494411?= X-GMAIL-MSGID: =?utf-8?q?1766041072630494411?= 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