[compiler-rt] r188291 - tsan: intercept getaddrinfo
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Aug 14 01:03:22 PDT 2013
We already have a common interceptor for getaddrinfo.
How does this even work?
On Wed, Aug 14, 2013 at 9:17 AM, Kostya Serebryany <kcc at google.com> wrote:
> Do we have a test?
>
>
> On Tue, Aug 13, 2013 at 8:51 PM, Dmitry Vyukov <dvyukov at google.com> wrote:
>>
>> Author: dvyukov
>> Date: Tue Aug 13 11:51:27 2013
>> New Revision: 188291
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=188291&view=rev
>> Log:
>> tsan: intercept getaddrinfo
>> This is necessary to prevent false positives, see:
>> https://code.google.com/p/thread-sanitizer/issues/detail?id=25
>>
>>
>> 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=188291&r1=188290&r2=188291&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
>> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Tue Aug 13
>> 11:51:27 2013
>> @@ -1735,6 +1735,20 @@ TSAN_INTERCEPTOR(int, gettimeofday, void
>> return REAL(gettimeofday)(tv, tz);
>> }
>>
>> +TSAN_INTERCEPTOR(int, getaddrinfo, void *node, void *service,
>> + void *hints, void *rv) {
>> + SCOPED_TSAN_INTERCEPTOR(getaddrinfo, node, service, hints, rv);
>> + // We miss atomic synchronization in getaddrinfo,
>> + // and can report false race between malloc and free
>> + // inside of getaddrinfo. So ignore memory accesses.
>> + IgnoreCtl(thr, true, true);
>> + IgnoreCtl(thr, false, true);
>> + int res = REAL(getaddrinfo)(node, service, hints, rv);
>> + IgnoreCtl(thr, true, false);
>> + IgnoreCtl(thr, false, false);
>
>
> The combination of 8 bool values looks bad.
> Can we have short names somewhere, like void IgnoreReadsBegin(thr)
> {IgnoreCtl(thr, false, true)} ?
>
> -kcc
>
>
>>
>> + return res;
>> +}
>> +
>> // Linux kernel has a bug that leads to kernel deadlock if a process
>> // maps TBs of memory and then calls mlock().
>> static void MlockIsUnsupported() {
>> @@ -2056,6 +2070,7 @@ void InitializeInterceptors() {
>> TSAN_INTERCEPT(usleep);
>> TSAN_INTERCEPT(nanosleep);
>> TSAN_INTERCEPT(gettimeofday);
>> + TSAN_INTERCEPT(getaddrinfo);
>>
>> TSAN_INTERCEPT(mlock);
>> TSAN_INTERCEPT(munlock);
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list