[compiler-rt] r353385 - tsan: Implement pthread_exit() interceptor for Thread sanitizer

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 8 00:13:30 PST 2019


Hi Alex,

Strictly saying this is not my change. I've copied this to review
thread where the author should receive it:
https://reviews.llvm.org/D57876
Please subscribe there for updates.

On Fri, Feb 8, 2019 at 1:17 AM Alex L <arphaman at gmail.com> wrote:
>
> Hi Dmitry,
>
> It looks like your change has caused a failure of the `Darwin/dispatch_main.mm` TSAN test on our CI:
>
> ******************** TEST 'ThreadSanitizer-x86_64-iossim :: Darwin/dispatch_main.mm' FAILED ********************
> Script:
> --
> : 'RUN: at line 4';     /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm/projects/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/clang-build/./bin/clang  -fsanitize=thread -Wall  -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk   -gline-tables-only -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm/projects/compiler-rt/test/tsan/../ /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm/projects/compiler-rt/test/tsan/Darwin/dispatch_main.mm -o /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/clang-build/tools/clang/runtime/compiler-rt-bins/test/tsan/IOSSimX86_64Config/Darwin/Output/dispatch_main.mm.tmp -framework Foundation
> : 'RUN: at line 5';   /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm/projects/compiler-rt/test/sanitizer_common/ios_commands/iossim_run.py /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/clang-build/tools/clang/runtime/compiler-rt-bins/test/tsan/IOSSimX86_64Config/Darwin/Output/dispatch_main.mm.tmp 2>&1 | FileCheck /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm/projects/compiler-rt/test/tsan/Darwin/dispatch_main.mm
> --
> Exit Code: 66
>
>
> ********************
>
> Here's the full log:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/13539/console
>
> I narrowed it down to your commit.
> You can reproduce it by running 'check-tsan' on macOS with the following CMake options "-DCMAKE_BUILD_TYPE=Release" "-DLLVM_ENABLE_ASSERTIONS=On" "-DLLVM_ENABLE_EXPENSIVE_CHECK=ON".
>
> Could you please take a look?
>
> Thanks,
> Alex
>
>
>
> On Thu, 7 Feb 2019 at 02:45, Dmitry Vyukov via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: dvyukov
>> Date: Thu Feb  7 02:46:02 2019
>> New Revision: 353385
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=353385&view=rev
>> Log:
>> tsan: Implement pthread_exit() interceptor for Thread sanitizer
>>
>> This change is preparation for fiber support.
>>
>> Author: yuri (Yuri Per)
>> Reviewed in: https://reviews.llvm.org/D57876
>> Context: https://reviews.llvm.org/D54889
>>
>>
>> Added:
>>     compiler-rt/trunk/test/tsan/thread_exit.c
>> Modified:
>>     compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
>>
>> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=353385&r1=353384&r2=353385&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
>> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Thu Feb  7 02:46:02 2019
>> @@ -1050,6 +1050,11 @@ TSAN_INTERCEPTOR(int, pthread_detach, vo
>>    return res;
>>  }
>>
>> +TSAN_INTERCEPTOR(void, pthread_exit, void *retval) {
>> +  SCOPED_TSAN_INTERCEPTOR(pthread_exit, retval);
>> +  REAL(pthread_exit)(retval);
>> +}
>> +
>>  #if SANITIZER_LINUX
>>  TSAN_INTERCEPTOR(int, pthread_tryjoin_np, void *th, void **ret) {
>>    SCOPED_TSAN_INTERCEPTOR(pthread_tryjoin_np, th, ret);
>> @@ -2664,6 +2669,7 @@ void InitializeInterceptors() {
>>    TSAN_INTERCEPT(pthread_create);
>>    TSAN_INTERCEPT(pthread_join);
>>    TSAN_INTERCEPT(pthread_detach);
>> +  TSAN_INTERCEPT(pthread_exit);
>>    #if SANITIZER_LINUX
>>    TSAN_INTERCEPT(pthread_tryjoin_np);
>>    TSAN_INTERCEPT(pthread_timedjoin_np);
>>
>> Added: compiler-rt/trunk/test/tsan/thread_exit.c
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/thread_exit.c?rev=353385&view=auto
>> ==============================================================================
>> --- compiler-rt/trunk/test/tsan/thread_exit.c (added)
>> +++ compiler-rt/trunk/test/tsan/thread_exit.c Thu Feb  7 02:46:02 2019
>> @@ -0,0 +1,25 @@
>> +// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
>> +#include "test.h"
>> +
>> +int var;
>> +
>> +void *Thread(void *x) {
>> +  pthread_exit(&var);
>> +  return 0;
>> +}
>> +
>> +int main() {
>> +  pthread_t t;
>> +  pthread_create(&t, 0, Thread, 0);
>> +  void *retval = 0;
>> +  pthread_join(t, &retval);
>> +  if (retval != &var) {
>> +    fprintf(stderr, "Unexpected return value\n");
>> +    exit(1);
>> +  }
>> +  fprintf(stderr, "PASS\n");
>> +  return 0;
>> +}
>> +
>> +// CHECK-NOT: WARNING: ThreadSanitizer:
>> +// CHECK: PASS
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list