blob: 23fb7cc12c419c5908ea39f5ce450a734ea11441 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
From f88f2ead8cc5958262d333c46e94ddc8a3c9ae18 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
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
|