From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smarthost01a.ixn.mail.zen.net.uk (smarthost01a.ixn.mail.zen.net.uk [212.23.1.20]) by sourceware.org (Postfix) with ESMTPS id A6C073858433; Mon, 15 May 2023 12:03:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6C073858433 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=mcrowe.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mcrowe.com Received: from [88.97.37.36] (helo=deneb.mcrowe.com) by smarthost01a.ixn.mail.zen.net.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyWvE-00080h-7W; Mon, 15 May 2023 12:03:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mcrowe.com; s=20191005; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=Ih/rwZ3BXYqxjXkXlp7xlTEw19BrLy0OYm4t4S/o1BI=; b=P/L6T ssUOW53vk4Wq7xlNdmsGffEOYJKbLNR/AEWxNXcYyK0f82mBvb+bdqk8Oa76pl6Acqcr1wyxbFlr/ Dj8EI6qG4VDTbnt0HXtxJ5NZOtt/sG/lQnzf5JOX6n3Ov55UpKKh4Ss7kzrRKZMjwfX4kSW2xRfrd 5iKgQukLSacfmxdbTvEE0JRhxvgBndoH/3A43/kRwH0AnSvojwxk9oKQ/sT4QhdMvCp7iXf1qtI+X yRSCEivLgQBahAHaGJswA0S33W7zt0PLAV39oZFfTuUANKFvmWbzv/LUrf2q4dAmRv/LcSaGQj0K9 sbMC9rRe/NkU+pSwPdXgsVbAsUAdQ==; Received: from mac by deneb.mcrowe.com with local (Exim 4.94.2) (envelope-from ) id 1pyWvD-001nAw-OE; Mon, 15 May 2023 13:03:23 +0100 Date: Mon, 15 May 2023 13:03:23 +0100 From: Mike Crowe To: Jonathan Wakely Cc: libstdc++ , gcc Patches , Thomas Rodgers Subject: Re: [PATCH v2] libstdc++: Do not use pthread_mutex_clocklock with ThreadSanitizer Message-ID: References: <20230510112009.633444-1-jwakely@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Originating-smarthost01a-IP: [88.97.37.36] Feedback-ID: 88.97.37.36 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,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: On Friday 12 May 2023 at 11:32:56 +0100, Jonathan Wakely wrote: > On Fri, 12 May 2023 at 11:30, Mike Crowe wrote: > > On Thursday 11 May 2023 at 21:52:22 +0100, Jonathan Wakely wrote: > > > On Thu, 11 May 2023 at 13:42, Jonathan Wakely > > wrote: > > > > On Thu, 11 May 2023 at 13:19, Mike Crowe wrote: > > > >> However, ... > > > >> > > > >> > > diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 > > > >> > > index 89e7f5f5f45..e2700b05ec3 100644 > > > >> > > --- a/libstdc++-v3/acinclude.m4 > > > >> > > +++ b/libstdc++-v3/acinclude.m4 > > > >> > > @@ -4284,7 +4284,7 @@ > > > >> AC_DEFUN([GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT], [ > > > >> > > [glibcxx_cv_PTHREAD_COND_CLOCKWAIT=no]) > > > >> > > ]) > > > >> > > if test $glibcxx_cv_PTHREAD_COND_CLOCKWAIT = yes; then > > > >> > > - AC_DEFINE(_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT, 1, [Define if > > > >> > > pthread_cond_clockwait is available in .]) > > > >> > > + AC_DEFINE(_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT, > > > >> (_GLIBCXX_TSAN==0), > > > >> > > [Define if pthread_cond_clockwait is available in .]) > > > >> > > fi > > > >> > > > >> TSan does appear to have an interceptor for pthread_cond_clockwait, > > even > > > >> if > > > >> it lacks the others. Does this mean that this part is unnecessary? > > > >> > > > > > > > > Ah good point, thanks. I grepped for clocklock but not clockwait. > > > > > > > > > > In fact it seems like we don't need to change > > > _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK either, because I don't get any > > tsan > > > warnings for that. It doesn't have interceptors for > > > pthread_rwlock_{rd,wr}lock, but it doesn't complain anyway (maybe it's > > > simply not instrumenting the rwlock functions at all?!) > > > > It looks like TSan does have interceptors for pthread_rwlock_timedrdlock > > etc. I can't explain why this doesn't cause problems when libstdc++ uses > > pthread_rwlock_clockrdlock etc. > > > > I think glibc has renamed the rwlock functions, and so the interceptors no > longer work. > > # ifdef __USE_XOPEN2K > /* Try to acquire read lock for RWLOCK or return after specfied time. */ > # ifndef __USE_TIME_BITS64 > extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict > __rwlock, > const struct timespec *__restrict > __abstime) __THROWNL __nonnull ((1, 2)); > # else > # ifdef __REDIRECT_NTHNL > extern int __REDIRECT_NTHNL (pthread_rwlock_timedrdlock, > (pthread_rwlock_t *__restrict __rwlock, > const struct timespec *__restrict __abstime), > __pthread_rwlock_timedrdlock64) > __nonnull ((1, 2)); > # else > # define pthread_rwlock_timedrdlock __pthread_rwlock_timedrdlock64 > # endif > # endif > # endif > > If glibc is really providing a function called > __pthread_rwlock_timedrdlock64 then will tsan be able to intercept that? I'm by no means an expert, but I would guess not. I suspect that the renaming was introduced as part of the Y2038 fixes and TSan hasn't caught up with them either. Mike.