From f88f2ead8cc5958262d333c46e94ddc8a3c9ae18 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 21 Nov 2017 12:10:34 +0100 Subject: [PATCH] fix stack overflow in epoll waiter musl libc has a default thread stack of 80k. avoid overflow the stack by allocating the epol_event array on heap instead of stack. --- bin/varnishd/waiter/cache_waiter_epoll.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 71c426a..ccbc64c 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -74,7 +74,7 @@ struct vwe { static void * vwe_thread(void *priv) { - struct epoll_event ev[NEEV], *ep; + struct epoll_event *ev, *ep; struct waited *wp; struct waiter *w; double now, then; @@ -87,6 +87,8 @@ vwe_thread(void *priv) CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-epoll"); THR_Init(); + ev = malloc(NEEV * sizeof(struct epoll_event)); + assert(ev != NULL); now = VTIM_real(); while (1) { @@ -154,6 +156,7 @@ vwe_thread(void *priv) AZ(close(vwe->pipe[0])); AZ(close(vwe->pipe[1])); AZ(close(vwe->epfd)); + free(ev); return (NULL); } -- 2.13.5