From 0813f5b97afe086a7b4d827774605b1f2e99191c Mon Sep 17 00:00:00 2001 From: Ashe Connor Date: Wed, 19 Sep 2018 16:36:47 +1000 Subject: [PATCH] unix: zero epoll_event before use Valgrind will emit the following error on a system where `int` is 32 bits: ==21616== Syscall param epoll_ctl(event) points to uninitialised byte(s) ==21616== at 0x693E06A: epoll_ctl (syscall-template.S:84) ==21616== by 0x529F35B: uv__io_poll (in .../libuv/libuv.so) ==21616== by 0x528AE62: uv_run (in .../libuv/libuv.so) [...] ==21616== Address 0x1ffeffc8ec is on thread 1's stack ==21616== in frame #1, created by uv__io_poll (???:) We only initialise e.events and e.data.fd, meaning half of e.data (the 32 bits not covered by the 4-byte `fd`) is uninitialised. PR-URL: https://github.com/libuv/libuv/pull/1996 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- src/unix/linux-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c index 991d1c60aee..3341b94e1f2 100644 --- a/src/unix/linux-core.c +++ b/src/unix/linux-core.c @@ -170,6 +170,7 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) { struct epoll_event e; int rc; + memset(&e, 0, sizeof(e)); e.events = POLLIN; e.data.fd = -1; @@ -218,6 +219,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { return; } + memset(&e, 0, sizeof(e)); + while (!QUEUE_EMPTY(&loop->watcher_queue)) { q = QUEUE_HEAD(&loop->watcher_queue); QUEUE_REMOVE(q);