summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2014-12-19 14:29:40 +0000
committerDmitry Vyukov <dvyukov@google.com>2014-12-19 14:29:40 +0000
commitb8a10ec2d253e6303713e4fd07b49b94f6d255bd (patch)
tree76dcff2953bde46c779e0861ab8343a9c9e08845
parent26485fadbd81edba2a3495e5aceb118ca8719386 (diff)
downloadcompiler-rt-b8a10ec2d253e6303713e4fd07b49b94f6d255bd.tar.gz
tsan: intercept closedir
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224575 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/tsan/rtl/tsan_interceptors.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors.cc
index b2bffe977..393d110b8 100644
--- a/lib/tsan/rtl/tsan_interceptors.cc
+++ b/lib/tsan/rtl/tsan_interceptors.cc
@@ -72,6 +72,7 @@ extern "C" void *__libc_malloc(uptr size);
extern "C" void *__libc_calloc(uptr size, uptr n);
extern "C" void *__libc_realloc(void *ptr, uptr size);
extern "C" void __libc_free(void *ptr);
+extern "C" int dirfd(void *dirp);
#if !SANITIZER_FREEBSD
extern "C" int mallopt(int param, int value);
#endif
@@ -1833,6 +1834,13 @@ TSAN_INTERCEPTOR(void*, opendir, char *path) {
return res;
}
+TSAN_INTERCEPTOR(int, closedir, void *dirp) {
+ SCOPED_TSAN_INTERCEPTOR(closedir, dirp);
+ int fd = dirfd(dirp);
+ FdClose(thr, pc, fd);
+ return REAL(closedir)(dirp);
+}
+
#if !SANITIZER_FREEBSD
TSAN_INTERCEPTOR(int, epoll_ctl, int epfd, int op, int fd, void *ev) {
SCOPED_TSAN_INTERCEPTOR(epoll_ctl, epfd, op, fd, ev);
@@ -2554,6 +2562,7 @@ void InitializeInterceptors() {
TSAN_INTERCEPT(puts);
TSAN_INTERCEPT(rmdir);
TSAN_INTERCEPT(opendir);
+ TSAN_INTERCEPT(closedir);
TSAN_MAYBE_INTERCEPT_EPOLL_CTL;
TSAN_MAYBE_INTERCEPT_EPOLL_WAIT;