Hello all, The patch and test case in the attachment demonstrate VCL_DelBackend() crashing on assertion failure, at least when called from a VMOD. It's failing AN(ptr) on line 288 of common/common_vsm.c, because be->vsc is NULL (VSM_Free(be->vsc) called by VBE_Event()).
The crash happens when you attempt to remove a statically declared backend. Oddly, I seem to have no problem at all calling VCL_DelBackend() on a dynamic backend created within the VMOD (using VRT_new_backend()). Bug report? (Are we still using trac for that, or are we into the Brave New World now?) I've noticed a few other strange things about VCL_DelBackend: - n_backend is evidently not decremented - the deleted backend still appears in the output of backend.list Best, Geoff -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstraße 32 22301 Hamburg Tel +49 40 2880 5731 Mob +49 176 636 90917 Fax +49 40 42949753 http://uplex.de
varnishtest "VCL_DelBackend"
server s1 {
} -start
varnish v1 -vcl {
import ${vmod_debug};
backend s1 { .host="${s1_addr}"; .port="${s1_port}"; }
sub vcl_recv {
if (req.method == "DELETE") {
if (debug.delete(s1)) {
return(synth(204, "No Content"));
}
else {
return(synth(404, "Not found"));
}
}
}
} -start
client c1 {
txreq -req "DELETE"
rxresp
expect resp.status == 204
txreq -req "DELETE"
rxresp
expect resp.status == 404
} -run
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index dad36ec..def1894 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -138,3 +138,5 @@ Mark a workspace as overflowed.
$Function INT workspace_free(ENUM { client, backend, session, thread })
Find how much unallocated space there is left in a workspace.
+
+$Function BOOL delete(BACKEND be)
diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c
index 7e4afea..31f4cb1 100644
--- a/lib/libvmod_debug/vmod_debug_dyn.c
+++ b/lib/libvmod_debug/vmod_debug_dyn.c
@@ -163,3 +163,23 @@ vmod_dyn_refresh(VRT_CTX, struct vmod_debug_dyn *dyn,
CHECK_OBJ_NOTNULL(dyn, VMOD_DEBUG_DYN_MAGIC);
dyn_dir_init(ctx, dyn, addr, port);
}
+
+VCL_BOOL __match_proto__()
+vmod_delete(VRT_CTX, VCL_BACKEND be)
+{
+ struct backend *backend;
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ if (be == NULL)
+ return 0;
+ CHECK_OBJ(be, DIRECTOR_MAGIC);
+
+ if (be->priv == NULL)
+ return 0;
+ backend = (struct backend *) be->priv;
+ if (backend->magic != BACKEND_MAGIC)
+ return 0;
+
+ VCL_DelBackend(backend);
+ return 1;
+}
signature.asc
Description: OpenPGP digital signature
_______________________________________________ varnish-dev mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
