cache_http1_fetch: Add V1L_Open() error handling

With the added test case but without the fix, we would see the panic shown
below.

Note that I do not see any way how this could be triggered in practice with the
current Varnish-Cache core code base.

Panic at: Mon, 28 Oct 2024 09:49:57 GMT
Assert error in V1L_Write(), http1/cache_http1_line.c line 275:
  Condition((v1l) != NULL) not true.
version = varnish-trunk revision 1b80876384763ffef02d395258401708a814bbb9, vrt api = 20.1
ident = Linux,6.1.0-25-amd64,x86_64,-jnone,-sdefault,-sdefault,-hcritbit,epoll
now = 47049.788459 (mono), 1730108997.304734 (real)
Backtrace:
  ip=0x5642a80acdc5 sp=0x7f20c5ca91d0 <VBT_format+0x35>
  ip=0x5642a7fe5c83 sp=0x7f20c5ca91f0 <pan_backtrace+0x33>
  ip=0x5642a7fe59ca sp=0x7f20c5ca9210 <pan_ic+0x37a>
  ip=0x5642a80abff5 sp=0x7f20c5ca9390 <VAS_Fail+0x55>
  ip=0x5642a80356a3 sp=0x7f20c5ca93e0 <V1L_Write+0xd3>
  ip=0x5642a803850b sp=0x7f20c5ca9420 <http1_WrTxt+0x1cb>
  ip=0x5642a8038263 sp=0x7f20c5ca9450 <HTTP1_Write+0x193>
  ip=0x5642a80314ef sp=0x7f20c5ca9480 <V1F_SendReq+0x5df>
  ip=0x5642a7fa5cc0 sp=0x7f20c5ca95b0 <vbe_dir_gethdrs+0x680>
  ip=0x5642a7fba2de sp=0x7f20c5ca9610 <VDI_GetHdr+0x16e>
  ip=0x5642a7fc9967 sp=0x7f20c5ca96d0 <vbf_stp_startfetch+0x487>
  ip=0x5642a7fc8894 sp=0x7f20c5ca9730 <vbf_fetch_thread+0x5f4>
  ip=0x5642a8023f17 sp=0x7f20c5ca9810 <Pool_Work_Thread+0x7c7>
  ip=0x5642a8023613 sp=0x7f20c5ca98a0 <WRK_Thread+0x333>
  ip=0x5642a802329b sp=0x7f20c5caa430 <pool_thread+0xcb>
  ip=0x7f20c61c9144 sp=0x7f20c5caa460 <pthread_condattr_setpshared+0x4e4>
  ip=0x7f20c62497dc sp=0x7f20c5caa500 <__xmknodat+0x23c>
parent 08a898f0
......@@ -100,7 +100,17 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
if (bo->vdp_filter_list != NULL &&
VCL_StackVDP(vdc, bo->vcl, bo->vdp_filter_list, NULL, bo))
err = "Failure to push processors";
else if (V1L_Open(wrk, wrk->aws, htc->rfd, bo->vsl, nan(""), 0),
wrk->v1l == NULL) {
/* ^^^^^^
* XXX: need a send_timeout for the backend side
* XXX: use cache_param->http1_iovs ?
*/
(void) VDP_Close(vdc, NULL, NULL);
err = "Failure to open V1L (workspace_thread overflow)";
}
else if (v1f_stackv1l(vdc, bo)) {
(void) V1L_Close(wrk, &bytes);
(void) VDP_Close(vdc, NULL, NULL);
err = "Failure to push V1L";
}
......@@ -116,9 +126,6 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
http_PrintfHeader(hp, "Transfer-Encoding: chunked");
VTCP_blocking(*htc->rfd); /* XXX: we should timeout instead */
/* XXX: need a send_timeout for the backend side */
// XXX cache_param->http1_iovs ?
V1L_Open(wrk, wrk->aws, htc->rfd, bo->vsl, nan(""), 0);
hdrbytes = HTTP1_Write(wrk, hp, HTTP1_Req);
/* Deal with any message-body the request might (still) have */
......
varnishtest "Out of thread workspace when opening V1L on the backend side"
server s1 {
non_fatal
rxreq
} -start
varnish v1 -vcl+backend {
import debug;
sub vcl_backend_fetch {
set bereq.filters += " debug.awshog";
return (fetch);
}
} -start
client c1 {
txreq -req "POST" -body "abc"
rxresp
expect resp.status == 503
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment