forked from OSchip/llvm-project
[tsan] Fix false positive on xdr*_create.
llvm-svn: 206030
This commit is contained in:
parent
1fcbe675fa
commit
652cbd7c15
|
@ -3714,7 +3714,7 @@ INTERCEPTOR(void, xdrmem_create, __sanitizer_XDR *xdrs, uptr addr,
|
|||
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, __sanitizer_XDR *xdrs, void *file, int op) {
|
|||
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) \
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue