tsan: fix epoll_ctl interceptor
Currently data-race-test unittests fail with the following false positive:
WARNING: ThreadSanitizer: data race (pid=20365)
Write of size 8 at 0x7da000008050 by thread T54:
#0 close tsan_interceptors.cc:1483 (racecheck_unittest-linux-amd64-O0+0x0000000eb34a)
#1 NegativeTests_epoll::Worker2() unittest/posix_tests.cc:1148 (racecheck_unittest-linux-amd64-O0+0x0000000cc6b1)
#2 MyThread::ThreadBody(MyThread*) unittest/./thread_wrappers_pthread.h:367 (racecheck_unittest-linux-amd64-O0+0x000000097500)
Previous read of size 8 at 0x7da000008050 by thread T49:
#0 epoll_ctl tsan_interceptors.cc:1646 (racecheck_unittest-linux-amd64-O0+0x0000000e9fee)
#1 NegativeTests_epoll::Worker1() unittest/posix_tests.cc:1140 (racecheck_unittest-linux-amd64-O0+0x0000000cc5b5)
#2 MyThread::ThreadBody(MyThread*) unittest/./thread_wrappers_pthread.h:367 (racecheck_unittest-linux-amd64-O0+0x000000097500)
llvm-svn: 192448
This commit is contained in:
parent
3d0933c425
commit
c9f9ada48d
|
|
@ -1645,21 +1645,23 @@ TSAN_INTERCEPTOR(void*, opendir, char *path) {
|
|||
|
||||
TSAN_INTERCEPTOR(int, epoll_ctl, int epfd, int op, int fd, void *ev) {
|
||||
SCOPED_TSAN_INTERCEPTOR(epoll_ctl, epfd, op, fd, ev);
|
||||
if (op == EPOLL_CTL_ADD && epfd >= 0) {
|
||||
FdRelease(thr, pc, epfd);
|
||||
}
|
||||
int res = REAL(epoll_ctl)(epfd, op, fd, ev);
|
||||
if (fd >= 0)
|
||||
if (epfd >= 0)
|
||||
FdAccess(thr, pc, epfd);
|
||||
if (epfd >= 0 && fd >= 0)
|
||||
FdAccess(thr, pc, fd);
|
||||
if (op == EPOLL_CTL_ADD && epfd >= 0)
|
||||
FdRelease(thr, pc, epfd);
|
||||
int res = REAL(epoll_ctl)(epfd, op, fd, ev);
|
||||
return res;
|
||||
}
|
||||
|
||||
TSAN_INTERCEPTOR(int, epoll_wait, int epfd, void *ev, int cnt, int timeout) {
|
||||
SCOPED_TSAN_INTERCEPTOR(epoll_wait, epfd, ev, cnt, timeout);
|
||||
if (epfd >= 0)
|
||||
FdAccess(thr, pc, epfd);
|
||||
int res = BLOCK_REAL(epoll_wait)(epfd, ev, cnt, timeout);
|
||||
if (res > 0 && epfd >= 0) {
|
||||
if (res > 0 && epfd >= 0)
|
||||
FdAcquire(thr, pc, epfd);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue