From: Mike Crowe <mac@mcrowe.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>,
gcc Patches <gcc-patches@gcc.gnu.org>,
Thomas Rodgers <trodgers@redhat.com>
Subject: Re: [PATCH v2] libstdc++: Do not use pthread_mutex_clocklock with ThreadSanitizer
Date: Mon, 15 May 2023 13:03:23 +0100 [thread overview]
Message-ID: <ZGIfi2LN7mqSSnNs@mcrowe.com> (raw)
In-Reply-To: <CACb0b4nT9dZRnzZb1U40Yz5BBAu+usYB9RoBQi8krwPk-G=qKA@mail.gmail.com>
On Friday 12 May 2023 at 11:32:56 +0100, Jonathan Wakely wrote:
> On Fri, 12 May 2023 at 11:30, Mike Crowe <mac@mcrowe.com> wrote:
> > On Thursday 11 May 2023 at 21:52:22 +0100, Jonathan Wakely wrote:
> > > On Thu, 11 May 2023 at 13:42, Jonathan Wakely <jwakely@redhat.com>
> > wrote:
> > > > On Thu, 11 May 2023 at 13:19, Mike Crowe <mac@mcrowe.com> 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 <pthread.h>.])
> > > >> > > + AC_DEFINE(_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT,
> > > >> (_GLIBCXX_TSAN==0),
> > > >> > > [Define if pthread_cond_clockwait is available in <pthread.h>.])
> > > >> > > 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.
next prev parent reply other threads:[~2023-05-15 12:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 11:20 [RFC] " Jonathan Wakely
2023-05-10 11:31 ` Jonathan Wakely
2023-05-11 12:19 ` Mike Crowe
2023-05-11 12:42 ` Jonathan Wakely
2023-05-11 20:52 ` [PATCH v2] " Jonathan Wakely
2023-05-12 10:30 ` Mike Crowe
2023-05-12 10:32 ` Jonathan Wakely
2023-05-15 12:03 ` Mike Crowe [this message]
2023-05-15 19:58 ` Thomas Rodgers
2023-05-11 15:54 ` [RFC] " Thomas Rodgers
2023-05-11 16:04 ` Jonathan Wakely
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=ZGIfi2LN7mqSSnNs@mcrowe.com \
--to=mac@mcrowe.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
--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).