commit 4fc14825c125eece32980df21d09da35e3d5bac6 Author: Jonathan Wakely Date: Tue May 9 09:30:48 2023 libstdc++: Do not use pthread_mutex_clocklock with ThreadSanitizer 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. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK): Define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK in terms of _GLIBCXX_TSAN. * configure: Regenerate. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 89e7f5f5f45..dce3d16aa5c 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"