Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look into running integration tests with valgrind #35

Open
TysonAndre opened this issue Apr 27, 2021 · 0 comments
Open

Look into running integration tests with valgrind #35

TysonAndre opened this issue Apr 27, 2021 · 0 comments

Comments

@TysonAndre
Copy link

TysonAndre commented Apr 27, 2021

  1. Identify possible memory leaks (not practical, this exits without cleaning up in most cases)
  2. Identify invalid memory accesses
diff --git a/src/event/nc_epoll.c b/src/event/nc_epoll.c
index 33aff85..c5b0a1a 100644
--- a/src/event/nc_epoll.c
+++ b/src/event/nc_epoll.c
@@ -103,6 +103,7 @@ event_add_in(struct event_base *evb, struct conn *c)
     }
 
     event.events = (uint32_t)(EPOLLIN | EPOLLET);
+    memset(&event.data, 0, sizeof(event.data));
     event.data.ptr = c;
 
     status = epoll_ctl(ep, EPOLL_CTL_MOD, c->sd, &event);
@@ -139,6 +140,7 @@ event_add_out(struct event_base *evb, struct conn *c)
     }
 
     event.events = (uint32_t)(EPOLLIN | EPOLLOUT | EPOLLET);
+    memset(&event.data, 0, sizeof(event.data));
     event.data.ptr = c;
 
     status = epoll_ctl(ep, EPOLL_CTL_MOD, c->sd, &event);
@@ -169,6 +171,7 @@ event_del_out(struct event_base *evb, struct conn *c)
     }
 
     event.events = (uint32_t)(EPOLLIN | EPOLLET);
+    memset(&event.data, 0, sizeof(event.data));
     event.data.ptr = c;
 
     status = epoll_ctl(ep, EPOLL_CTL_MOD, c->sd, &event);
@@ -194,6 +197,7 @@ event_add_conn(struct event_base *evb, struct conn *c)
     ASSERT(c->sd > 0);
 
     event.events = (uint32_t)(EPOLLIN | EPOLLOUT | EPOLLET);
+    memset(&event.data, 0, sizeof(event.data));
     event.data.ptr = c;
 
     status = epoll_ctl(ep, EPOLL_CTL_ADD, c->sd, &event);
@@ -307,6 +311,7 @@ event_loop_stats(event_stats_cb_t cb, void *arg)
         return;
     }
 
+    memset(&ev.data, 0, sizeof(ev.data));
     ev.data.fd = st->sd;
     ev.events = EPOLLIN;

Because event.data is a union the stats code for fd is a false positive for valgrind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant