Fix aside should we consider using sigaltstack to also catch these crashes?
I imagine something like the attached but allocated on startup and shared
among all workers.

This might be specific to pcre at the moment but I can see its usefulness
in the vmod world.




On Tue, Sep 2, 2014 at 9:08 PM, Nils Goroll <[email protected]> wrote:

>
>
> On 02/09/14 21:50, Nils Goroll wrote:
> > On 02/09/14 21:45, Poul-Henning Kamp wrote:
> >> What we really need is for pcre to tell us an estimate of how much
> >> stack-space is needed during compilation
> >
> > Is this possible? My understanding is that the recursion depth depends
> on the
> > data and thus all we can do is set a recursion limit for the stack size
> we have
> > available.
>
> This sounds close to the answer we are looking for:
>
> https://lists.exim.org/lurker/message/20130417.155604.5223f8b8.en.html
>
>
> > Is there a way to get some "stats" for a regexp like max recursion
> > depth, taken branches, steps needed for solution, ...?
>
> The pcretest program has a facility for determining the max recursion
> depth, given a pattern and a subject string. Grep for \M in the pcretest
> man page.
>
> pcretest(1):
>
>  If \M is present, pcretest calls pcre_exec() several times, with different
> values in the match_limit and match_limit_recursion fields of the
> pcre_extra
> data structure, until it finds the minimum numbers for each parameter that
> allow
> pcre_exec() to complete.
>
>
> _______________________________________________
> varnish-dev mailing list
> [email protected]
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 38a662b..0d8b221 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -33,6 +33,7 @@
 
 #include <math.h>
 #include <stdlib.h>
+#include <signal.h>
 
 #include "cache.h"
 
@@ -90,6 +91,18 @@ wrk_thread_real(void *priv, unsigned thread_workspace)
 	struct worker *w, ww;
 	unsigned char ws[thread_workspace];
 
+#ifdef HAVE_SIGALTSTACK
+	if (cache_param->sigsegv_handler) {
+		char stackbuf[MINSIGSTKSZ];
+		stack_t ss;
+
+		ss.ss_size = sizeof(stackbuf);
+		ss.ss_sp = stackbuf;
+		ss.ss_flags = 0;
+		(void)sigaltstack(&ss, NULL);
+	}
+#endif
+
 	THR_SetName("cache-worker");
 	w = &ww;
 	memset(w, 0, sizeof *w);
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index 7c777de..3038bd1 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -415,7 +415,7 @@ mgt_launch_child(struct cli *cli)
 		if (mgt_param.sigsegv_handler) {
 			memset(&sa, 0, sizeof sa);
 			sa.sa_sigaction = child_sigsegv_handler;
-			sa.sa_flags = SA_SIGINFO;
+			sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
 			(void)sigaction(SIGSEGV, &sa, NULL);
 		}
 		(void)signal(SIGINT, SIG_DFL);
diff --git a/configure.ac b/configure.ac
index d4f5c5b..817bc3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -205,6 +205,7 @@ AC_CHECK_FUNCS([getdtablesize])
 AC_CHECK_FUNCS([timegm])
 AC_CHECK_FUNCS([nanosleep])
 AC_CHECK_FUNCS([setppriv])
+AC_CHECK_FUNCS([sigaltstack])
 
 save_LIBS="${LIBS}"
 LIBS="${PTHREAD_LIBS}"
_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to