Mailing List Archive

[master] fe96d9828 Release the panicstr_mtx before calling abort(2), but still protect against reentrancy.
commit fe96d9828b263c903adfd7d4a90e2d7a9abc20cf
Author: Poul-Henning Kamp <phk@FreeBSD.org>
Date: Tue Sep 21 08:12:19 2021 +0000

Release the panicstr_mtx before calling abort(2), but still protect against reentrancy.

Fixes: #3688

diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 190ac90b7..3d01e6090 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -718,9 +718,11 @@ 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)); /* Won't be released,
- we're going to die
- anyway */
+ AZ(pthread_mutex_lock(&panicstr_mtx));
+
+ /* If we already panic'ed, do nothing */
+ while (heritage.panic_str[0])
+ sleep(1);

/*
* should we trigger a SIGSEGV while handling a panic, our sigsegv
@@ -809,6 +811,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
VSB_putc(pan_vsb, '\0'); /* NUL termination */

v_gcov_flush();
+ AZ(pthread_mutex_unlock(&panicstr_mtx));
abort();
}

_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit