[libcxx] r293197 - Disable thread safety analysis for some functions in __thread_support

Dimitry Andric via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 29 12:42:49 PST 2017


Thanks, merged in r293443.

-Dimitry

> On 29 Jan 2017, at 19:55, Eric Fiselier <eric at efcs.ca> wrote:
> 
> I'm OK with this.
> 
> On Sun, Jan 29, 2017 at 10:18 AM, Dimitry Andric <dimitry at andric.com <mailto:dimitry at andric.com>> wrote:
> I'd like to merge this to the release_40 branch.  Eric, you OK with that?
> 
> -Dimitry
> 
> > On 26 Jan 2017, at 19:37, Dimitry Andric via cfe-commits <cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>> wrote:
> >
> > Author: dim
> > Date: Thu Jan 26 12:37:18 2017
> > New Revision: 293197
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=293197&view=rev <http://llvm.org/viewvc/llvm-project?rev=293197&view=rev>
> > Log:
> > Disable thread safety analysis for some functions in __thread_support
> >
> > Many thread-related libc++ test cases fail on FreeBSD, due to the
> > following -Werror warnings:
> >
> >    In file included from test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp:17:
> >    In file included from include/thread:97:
> >    In file included from include/__mutex_base:17:
> >    include/__threading_support:222:1: error: mutex '__m' is still held at the end of function [-Werror,-Wthread-safety-analysis]
> >    }
> >    ^
> >    include/__threading_support:221:10: note: mutex acquired here
> >      return pthread_mutex_lock(__m);
> >             ^
> >    include/__threading_support:231:10: error: releasing mutex '__m' that was not held [-Werror,-Wthread-safety-analysis]
> >      return pthread_mutex_unlock(__m);
> >             ^
> >    include/__threading_support:242:1: error: mutex '__m' is still held at the end of function [-Werror,-Wthread-safety-analysis]
> >    }
> >    ^
> >    include/__threading_support:241:10: note: mutex acquired here
> >      return pthread_mutex_lock(__m);
> >             ^
> >    include/__threading_support:251:10: error: releasing mutex '__m' that was not held [-Werror,-Wthread-safety-analysis]
> >      return pthread_mutex_unlock(__m);
> >             ^
> >    include/__threading_support:272:10: error: calling function 'pthread_cond_wait' requires holding mutex '__m' exclusively [-Werror,-Wthread-safety-analysis]
> >      return pthread_cond_wait(__cv, __m);
> >             ^
> >    include/__threading_support:278:10: error: calling function 'pthread_cond_timedwait' requires holding mutex '__m' exclusively [-Werror,-Wthread-safety-analysis]
> >      return pthread_cond_timedwait(__cv, __m, __ts);
> >             ^
> >    6 errors generated.
> >
> > This is because on FreeBSD, the pthread functions have lock annotations.
> > Since the functions in __thread_support are internal to libc++ only, add
> > no_thread_safety_analysis attributes to suppress these warnings.
> >
> > Reviewers: mclow.lists, EricWF, delesley, aaron.ballman
> > Reviewed By: aaron.ballman
> > Subscribers: ed, aaron.ballman, joerg, emaste, cfe-commits
> > Differential Revision: https://reviews.llvm.org/D28520 <https://reviews.llvm.org/D28520>
> >
> > Modified:
> >    libcxx/trunk/include/__threading_support
> >
> > Modified: libcxx/trunk/include/__threading_support
> > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=293197&r1=293196&r2=293197&view=diff <http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=293197&r1=293196&r2=293197&view=diff>
> > ==============================================================================
> > --- libcxx/trunk/include/__threading_support (original)
> > +++ libcxx/trunk/include/__threading_support Thu Jan 26 12:37:18 2017
> > @@ -40,6 +40,12 @@
> > #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
> > #endif
> >
> > +#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis)
> > +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis))
> > +#else
> > +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > +#endif
> > +
> > _LIBCPP_BEGIN_NAMESPACE_STD
> >
> > #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
> > @@ -102,25 +108,25 @@ typedef DWORD __libcpp_tls_key;
> > _LIBCPP_THREAD_ABI_VISIBILITY
> > int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
> >
> > _LIBCPP_THREAD_ABI_VISIBILITY
> > int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
> >
> > _LIBCPP_THREAD_ABI_VISIBILITY
> > @@ -133,10 +139,10 @@ int __libcpp_condvar_signal(__libcpp_con
> > _LIBCPP_THREAD_ABI_VISIBILITY
> > int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
> >                                timespec *__ts);
> >
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170129/f3c6f3be/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170129/f3c6f3be/attachment.sig>


More information about the cfe-commits mailing list