[compiler-rt] r188291 - tsan: intercept getaddrinfo
Dmitry Vyukov
dvyukov at google.com
Tue Aug 13 09:51:27 PDT 2013
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);
+ 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);
More information about the llvm-commits
mailing list