> On Sep 19, 2016, at 09:52, Keith Packard <kei...@keithp.com> wrote:
> Jeremy Huddleston Sequoia <jerem...@apple.com> writes:
>> Yeah, I made the change mainly to shutup the analyzer while I was
>> looking for other races.  I decided to propose it in case we want to
>> be strict here.
> Thanks. Keeping our request processing overhead low seems important
> enough to me that we should skip this patch, although perhaps adding a
> comment before the test noting that we are intentionally not holding the
> input lock.
> Is there some way we can annotate the code to silence the analyzer in
> these cases?

The annotation is at a per-function level.  We can basically say "if you notice 
data races in this funciton, don't bother reporting them".  I'm doing this for 
a similar case where we want to limit overhead on the fastpath in 
darwinEvents.c.  In the code below, TSan would normally complain about the read 
of mieqInitialized without holding the mieqInitializedMutex, but we know it's 
actually safe in this case.

We could add something like _X_NOTSAN to Xfuncproto.h to cover this and then 
break out the actual comparisons into an inline function with that attribute.  
Breaking that out into separate inline functions allows us to surgically apply 


static BOOL mieqInitialized;
static pthread_mutex_t mieqInitializedMutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t mieqInitializedCond = PTHREAD_COND_INITIALIZER;

#ifdef __has_feature
# if __has_feature(thread_sanitizer)
#  define __tsan_ignore __attribute__((no_sanitize_thread))
# else
#  define __tsan_ignore /**/
# endif
# define __tsan_ignore /**/

extern inline void
    if (!mieqInitialized) {
        while (!mieqInitialized) {
            pthread_cond_wait(&mieqInitializedCond, &mieqInitializedMutex);

static inline void
    mieqInitialized = TRUE;

Attachment: smime.p7s
Description: S/MIME cryptographic signature

xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to