ext/libuv/src/unix/linux-syscalls.c in libuv-1.3.0 vs ext/libuv/src/unix/linux-syscalls.c in libuv-2.0.0
- old
+ new
@@ -24,10 +24,17 @@
#include <signal.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <errno.h>
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+# define MSAN_ACTIVE 1
+# include <sanitizer/msan_interface.h>
+# endif
+#endif
+
#if defined(__i386__)
# ifndef __NR_socketcall
# define __NR_socketcall 102
# endif
#endif
@@ -308,11 +315,17 @@
int uv__epoll_wait(int epfd,
struct uv__epoll_event* events,
int nevents,
int timeout) {
#if defined(__NR_epoll_wait)
- return syscall(__NR_epoll_wait, epfd, events, nevents, timeout);
+ int result;
+ result = syscall(__NR_epoll_wait, epfd, events, nevents, timeout);
+#if MSAN_ACTIVE
+ if (result > 0)
+ __msan_unpoison(events, sizeof(events[0]) * result);
+#endif
+ return result;
#else
return errno = ENOSYS, -1;
#endif
}
@@ -321,17 +334,23 @@
struct uv__epoll_event* events,
int nevents,
int timeout,
uint64_t sigmask) {
#if defined(__NR_epoll_pwait)
- return syscall(__NR_epoll_pwait,
- epfd,
- events,
- nevents,
- timeout,
- &sigmask,
- sizeof(sigmask));
+ int result;
+ result = syscall(__NR_epoll_pwait,
+ epfd,
+ events,
+ nevents,
+ timeout,
+ &sigmask,
+ sizeof(sigmask));
+#if MSAN_ACTIVE
+ if (result > 0)
+ __msan_unpoison(events, sizeof(events[0]) * result);
+#endif
+ return result;
#else
return errno = ENOSYS, -1;
#endif
}
@@ -372,10 +391,16 @@
}
int uv__pipe2(int pipefd[2], int flags) {
#if defined(__NR_pipe2)
- return syscall(__NR_pipe2, pipefd, flags);
+ int result;
+ result = syscall(__NR_pipe2, pipefd, flags);
+#if MSAN_ACTIVE
+ if (!result)
+ __msan_unpoison(pipefd, sizeof(int[2]));
+#endif
+ return result;
#else
return errno = ENOSYS, -1;
#endif
}