Mailing List Archive

[master] fd3d71b17 Try to handle reentrant panics more sensibly.
commit fd3d71b17eb9b3595b4d0fda297159b713d70f80
Author: Poul-Henning Kamp <phk@FreeBSD.org>
Date: Tue Jan 4 07:34:25 2022 +0000

Try to handle reentrant panics more sensibly.

Relevant to: #3764

diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 3ac6af736..734b801e3 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -67,6 +67,7 @@

static struct vsb pan_vsb_storage, *pan_vsb;
static pthread_mutex_t panicstr_mtx;
+static pthread_t panicy;

static void pan_sess(struct vsb *, const struct sess *);
static void pan_req(struct vsb *, const struct req *);
@@ -720,12 +721,17 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
struct sigaction sa;
int err = errno;

- AZ(pthread_mutex_lock(&panicstr_mtx));
-
- /* If we already panic'ed, do nothing */
- while (heritage.panic_str[0])
+ /* If we already panicing in another thread, do nothing */
+ while (heritage.panic_str[0] && panicy != pthread_self())
sleep(1);

+ if (pthread_mutex_lock(&panicstr_mtx)) {
+ /* Reentrant panic */
+ VSB_printf(pan_vsb,"\n\nPANIC REENTRANCY\n\n");
+ abort();
+ }
+ panicy = pthread_self();
+
/*
* should we trigger a SIGSEGV while handling a panic, our sigsegv
* handler would hide the panic, so we need to reset the handler to
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit