From owner-svn-src-all@freebsd.org Thu Dec 28 23:58:29 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D0501E8A212; Thu, 28 Dec 2017 23:58:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7C927274A; Thu, 28 Dec 2017 23:58:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBSNwS7A088105; Thu, 28 Dec 2017 23:58:28 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBSNwSeX088101; Thu, 28 Dec 2017 23:58:28 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201712282358.vBSNwSeX088101@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Thu, 28 Dec 2017 23:58:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r327323 - in vendor/compiler-rt/dist: lib/sanitizer_common lib/tsan/rtl test/msan X-SVN-Group: vendor X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in vendor/compiler-rt/dist: lib/sanitizer_common lib/tsan/rtl test/msan X-SVN-Commit-Revision: 327323 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Dec 2017 23:58:29 -0000 Author: dim Date: Thu Dec 28 23:58:28 2017 New Revision: 327323 URL: https://svnweb.freebsd.org/changeset/base/327323 Log: Vendor import of compiler-rt trunk r321545: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321545 Added: vendor/compiler-rt/dist/test/msan/pthread_getname_np.cc (contents, props changed) Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_interceptors.inc vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform_interceptors.h vendor/compiler-rt/dist/lib/tsan/rtl/tsan_libdispatch_mac.cc Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_interceptors.inc ============================================================================== --- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_interceptors.inc Thu Dec 28 23:58:25 2017 (r327322) +++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_interceptors.inc Thu Dec 28 23:58:28 2017 (r327323) @@ -4551,6 +4551,20 @@ INTERCEPTOR(int, pthread_setname_np, uptr thread, cons #define INIT_PTHREAD_SETNAME_NP #endif +#if SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP +INTERCEPTOR(int, pthread_getname_np, uptr thread, char *name, SIZE_T len) { + void *ctx; + COMMON_INTERCEPTOR_ENTER(ctx, pthread_getname_np, thread, name, len); + int res = REAL(pthread_getname_np)(thread, name, len); + if (!res) + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, name, internal_strnlen(name, len) + 1); + return res; +} +#define INIT_PTHREAD_GETNAME_NP COMMON_INTERCEPT_FUNCTION(pthread_getname_np); +#else +#define INIT_PTHREAD_GETNAME_NP +#endif + #if SANITIZER_INTERCEPT_SINCOS INTERCEPTOR(void, sincos, double x, double *sin, double *cos) { void *ctx; @@ -6541,6 +6555,7 @@ static void InitializeCommonInterceptors() { INIT_TTYNAME_R; INIT_TEMPNAM; INIT_PTHREAD_SETNAME_NP; + INIT_PTHREAD_GETNAME_NP; INIT_SINCOS; INIT_REMQUO; INIT_LGAMMA; Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform_interceptors.h ============================================================================== --- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform_interceptors.h Thu Dec 28 23:58:25 2017 (r327322) +++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform_interceptors.h Thu Dec 28 23:58:28 2017 (r327323) @@ -343,6 +343,8 @@ #define SANITIZER_INTERCEPT_PHTREAD_MUTEX SI_POSIX #define SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP \ (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) +#define SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP \ + (SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) #define SANITIZER_INTERCEPT_TLS_GET_ADDR \ (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) Modified: vendor/compiler-rt/dist/lib/tsan/rtl/tsan_libdispatch_mac.cc ============================================================================== --- vendor/compiler-rt/dist/lib/tsan/rtl/tsan_libdispatch_mac.cc Thu Dec 28 23:58:25 2017 (r327322) +++ vendor/compiler-rt/dist/lib/tsan/rtl/tsan_libdispatch_mac.cc Thu Dec 28 23:58:28 2017 (r327323) @@ -25,6 +25,11 @@ #include #include +// DISPATCH_NOESCAPE is not defined prior to XCode 8. +#ifndef DISPATCH_NOESCAPE +#define DISPATCH_NOESCAPE +#endif + typedef long long_t; // NOLINT namespace __tsan { Added: vendor/compiler-rt/dist/test/msan/pthread_getname_np.cc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/compiler-rt/dist/test/msan/pthread_getname_np.cc Thu Dec 28 23:58:28 2017 (r327323) @@ -0,0 +1,34 @@ +// RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %run %t +// UNSUPPORTED: android, netbsd + +// Regression test for a deadlock in pthread_getattr_np + +#include +#include +#include +#include + +#include + +void *ThreadFn(void *) { + return nullptr; +} + +int main(void) { + pthread_t t; + int res = pthread_create(&t, 0, ThreadFn, 0); + assert(!res); + + const char *kMyThreadName = "my-thread-name"; + res = pthread_setname_np(t, kMyThreadName); + assert(!res); + + char buf[100]; + res = pthread_getname_np(t, buf, sizeof(buf)); + assert(!res); + assert(strcmp(buf, kMyThreadName) == 0); + + res = pthread_join(t, 0); + assert(!res); + return 0; +}