[compiler-rt] r206030 - [tsan] Fix false positive on xdr*_create.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Apr 11 05:29:24 PDT 2014


Author: eugenis
Date: Fri Apr 11 07:29:24 2014
New Revision: 206030

URL: http://llvm.org/viewvc/llvm-project?rev=206030&view=rev
Log:
[tsan] Fix false positive on xdr*_create.

Added:
    compiler-rt/trunk/test/tsan/sunrpc.cc   (with props)
Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=206030&r1=206029&r2=206030&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Fri Apr 11 07:29:24 2014
@@ -3714,7 +3714,7 @@ INTERCEPTOR(void, xdrmem_create, __sanit
   COMMON_INTERCEPTOR_ENTER(ctx, xdrmem_create, xdrs, addr, size, op);
   REAL(xdrmem_create)(xdrs, addr, size, op);
   COMMON_INTERCEPTOR_WRITE_RANGE(ctx, xdrs, sizeof(*xdrs));
-  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, xdrs->x_ops, sizeof(*xdrs->x_ops));
+  COMMON_INTERCEPTOR_INITIALIZE_RANGE(xdrs->x_ops, sizeof(*xdrs->x_ops));
   if (op == __sanitizer_XDR_ENCODE) {
     // It's not obvious how much data individual xdr_ routines write.
     // Simply unpoison the entire target buffer in advance.
@@ -3727,7 +3727,7 @@ INTERCEPTOR(void, xdrstdio_create, __san
   COMMON_INTERCEPTOR_ENTER(ctx, xdrstdio_create, xdrs, file, op);
   REAL(xdrstdio_create)(xdrs, file, op);
   COMMON_INTERCEPTOR_WRITE_RANGE(ctx, xdrs, sizeof(*xdrs));
-  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, xdrs->x_ops, sizeof(*xdrs->x_ops));
+  COMMON_INTERCEPTOR_INITIALIZE_RANGE(xdrs->x_ops, sizeof(*xdrs->x_ops));
 }
 
 #define XDR_INTERCEPTOR(F, T)                             \

Added: compiler-rt/trunk/test/tsan/sunrpc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/sunrpc.cc?rev=206030&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/sunrpc.cc (added)
+++ compiler-rt/trunk/test/tsan/sunrpc.cc Fri Apr 11 07:29:24 2014
@@ -0,0 +1,21 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t
+
+#include <pthread.h>
+#include <rpc/xdr.h>
+
+void *thr(void *p) {
+  XDR xdrs;
+  char buf[100];
+  xdrmem_create(&xdrs, buf, sizeof(buf), XDR_ENCODE);
+  xdr_destroy(&xdrs);
+  return 0;
+}
+
+int main(int argc, char *argv[]) {
+  pthread_t th[2];
+  pthread_create(&th[0], 0, thr, 0);
+  pthread_create(&th[1], 0, thr, 0);
+  pthread_join(th[0], 0);
+  pthread_join(th[1], 0);
+  return 0;
+}

Propchange: compiler-rt/trunk/test/tsan/sunrpc.cc
------------------------------------------------------------------------------
    svn:eol-style = LF





More information about the llvm-commits mailing list