[6.0] d4ff5c553 improve busyobj panic

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Feb 5 16:30:16 UTC 2019


commit d4ff5c553a5fbf0dd816969c80e04a9e0bbd3289
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Nov 13 17:43:41 2018 +0100

    improve busyobj panic
    
    For backend requests, we do not have the thread local storage of the
    client thread available, so trq.req will normally be (nil).
    
    Dump the busyobj back pointers to req/sess/wrk to maximize the
    usefulness of panics.
    
    Also reorder the panic by struct busyobj and add some more members
    which may or may not be useful (but when we find out, it is likely
    too late).
    
    Also move the vmod list dump to the top level.
    
    Noticed when trying to understand if #2667 was also a stack overflow
    in the context of #2817
    
    Conflicts:
            bin/varnishd/cache/cache_panic.c

diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 8282ed814..d75e0b23f 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -61,6 +61,7 @@ static struct vsb pan_vsb_storage, *pan_vsb;
 static pthread_mutex_t panicstr_mtx;
 
 static void pan_sess(struct vsb *, const struct sess *);
+static void pan_req(struct vsb *, const struct req *);
 
 /*--------------------------------------------------------------------*/
 
@@ -400,8 +401,37 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo)
 		return;
 	VSB_indent(vsb, 2);
 	PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC);
+	VSB_printf(vsb, "end = %p,\n", bo->end);
+	VSB_printf(vsb, "retries = %d,\n", bo->retries);
+
+	if (bo->req != NULL)
+		pan_req(vsb, bo->req);
+	if (bo->sp != NULL)
+		pan_sess(vsb, bo->sp);
+	if (bo->wrk != NULL)
+		pan_wrk(vsb, bo->wrk);
+
+	if (bo->vfc != NULL)
+		pan_vfp(vsb, bo->vfc);
+
 	pan_ws(vsb, bo->ws);
-	VSB_printf(vsb, "retries = %d, ", bo->retries);
+	VSB_printf(vsb, "ws_bo = %p,\n", (void *)bo->ws_bo);
+
+	// bereq0 left out
+	if (bo->bereq != NULL && bo->bereq->ws != NULL)
+		pan_http(vsb, "bereq", bo->bereq);
+	if (bo->beresp != NULL && bo->beresp->ws != NULL)
+		pan_http(vsb, "beresp", bo->beresp);
+	if (bo->stale_oc)
+		pan_objcore(vsb, "stale_oc", bo->stale_oc);
+	if (bo->fetch_objcore)
+		pan_objcore(vsb, "fetch", bo->fetch_objcore);
+
+	if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC))
+		pan_htc(vsb, bo->htc);
+
+	// fetch_task left out
+
 	VSB_printf(vsb, "flags = {");
 	p = "";
 /*lint -save -esym(438,p) -e539 */
@@ -411,27 +441,14 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo)
 /*lint -restore */
 	VSB_printf(vsb, "},\n");
 
-	if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC))
-		pan_htc(vsb, bo->htc);
-
-	if (bo->vfc)
-		pan_vfp(vsb, bo->vfc);
+	// timeouts/timers/acct/storage left out
 
 	VDI_Panic(bo->director_req, vsb, "director_req");
 	if (bo->director_resp == bo->director_req)
 		VSB_printf(vsb, "director_resp = director_req,\n");
 	else
 		VDI_Panic(bo->director_resp, vsb, "director_resp");
-	if (bo->bereq != NULL && bo->bereq->ws != NULL)
-		pan_http(vsb, "bereq", bo->bereq);
-	if (bo->beresp != NULL && bo->beresp->ws != NULL)
-		pan_http(vsb, "beresp", bo->beresp);
-	if (bo->fetch_objcore)
-		pan_objcore(vsb, "fetch", bo->fetch_objcore);
-	if (bo->stale_oc)
-		pan_objcore(vsb, "ims", bo->stale_oc);
 	VCL_Panic(vsb, bo->vcl);
-	VMOD_Panic(vsb);
 	VSB_indent(vsb, -2);
 	VSB_printf(vsb, "},\n");
 }
@@ -496,7 +513,6 @@ pan_req(struct vsb *vsb, const struct req *req)
 		pan_http(vsb, "resp", req->resp);
 
 	VCL_Panic(vsb, req->vcl);
-	VMOD_Panic(vsb);
 
 	if (req->body_oc != NULL)
 		pan_objcore(vsb, "BODY", req->body_oc);
@@ -684,6 +700,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
 		pan_busyobj(pan_vsb, bo);
 		if (bo != NULL)
 			VSL_Flush(bo->vsl, 0);
+		VMOD_Panic(pan_vsb);
 	} else {
 		VSB_printf(pan_vsb,
 		    "Feature short panic supressed details.\n");


More information about the varnish-commit mailing list