blob: 67677b330602ecec578b149b82eb402b1c73a27c (
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 bc0b56b8703e7e02af745af28bc6fff48ab806ba Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 2 Mar 2016 10:46:49 +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 f50ae46..65719e5 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -71,7 +71,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;
@@ -83,6 +83,8 @@ vwe_thread(void *priv)
w = vwe->waiter;
CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
THR_SetName("cache-epoll");
+ ev = malloc(NEEV * sizeof(struct epoll_event));
+ assert(ev != NULL);
now = VTIM_real();
while (1) {
@@ -146,6 +148,7 @@ vwe_thread(void *priv)
AZ(close(vwe->pipe[0]));
AZ(close(vwe->pipe[1]));
AZ(close(vwe->epfd));
+ free(ev);
return (NULL);
}
--
2.7.2
|