[master] 3eec7e814 Avoid panic if director is already finalized for invalid range after rollback

Nils Goroll nils.goroll at uplex.de
Fri Aug 16 14:40:10 UTC 2024


commit 3eec7e814841425e71e47642bc603097aac7e102
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Aug 15 23:26:00 2024 +0200

    Avoid panic if director is already finalized for invalid range after rollback
    
    Fixes #4164

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 647201b7a..650ad26cf 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -499,7 +499,8 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 		bo->htc->doclose = SC_RESP_CLOSE;
 
 	if (VRG_CheckBo(bo) < 0) {
-		VDI_Finish(bo);
+		if (bo->director_state != DIR_S_NULL)
+			VDI_Finish(bo);
 		return (F_STP_ERROR);
 	}
 
diff --git a/bin/varnishtest/tests/r04164.vtc b/bin/varnishtest/tests/r04164.vtc
new file mode 100644
index 000000000..3c3f400d5
--- /dev/null
+++ b/bin/varnishtest/tests/r04164.vtc
@@ -0,0 +1,26 @@
+varnishtest "pass, rollback, invalid range"
+
+server s1 {
+	rxreq
+	expect req.url == "/baz"
+	txresp -status 400
+} -start
+
+varnish v1 -vcl+backend {
+	import std;
+
+	sub vcl_recv {
+		return (pass);
+	}
+	sub vcl_backend_response {
+		std.rollback(bereq);
+		return (retry);
+	}
+} -start
+
+client c1 {
+	txreq -url "/baz" -hdr "range: 42"
+	rxresp
+} -run
+
+server s1 -wait


More information about the varnish-commit mailing list