Add m00054.vtc: panic when calling sub from a wrong vcl

VMODs must not use SUB references across VCLs. This test checks for a
panic if they do.
parent 3b5015ca
varnishtest "VCL_SUB wrong vmod behavior"
varnish v1 -arg "-p feature=+no_coredump" -vcl {
import debug;
backend dummy None;
sub foo {
set resp.http.it = "works";
}
sub vcl_init {
debug.bad_memory(foo);
}
} -start
varnish v1 -vcl {
import debug;
backend dummy None;
sub vcl_recv {
debug.call(debug.total_recall());
}
}
client c1 {
txreq -url "/foo"
expect_close
} -run
varnish v1 -wait-stopped
varnish v1 -cliexpect "Assert error in VPI_Call_Check" "panic.show"
varnish v1 -cliok "panic.clear"
varnish v1 -expect MGT.child_panic == 1
varnish v1 -expectexit 0x40
......@@ -1309,3 +1309,25 @@ xyzzy_check_call(VRT_CTX, VCL_SUB sub)
{
return (VRT_check_call(ctx, sub));
}
/* the next two are to test WRONG vmod behavior:
* holding a VCL_SUB reference across vcls
*/
static VCL_SUB wrong = NULL;
VCL_VOID v_matchproto_(td_xyzzy_bad_memory)
xyzzy_bad_memory(VRT_CTX, VCL_SUB sub)
{
(void) ctx;
wrong = sub;
}
VCL_SUB v_matchproto_(td_xyzzy_total_recall)
xyzzy_total_recall(VRT_CTX)
{
(void) ctx;
return (wrong);
}
......@@ -332,3 +332,11 @@ string saying why not.
$Function VOID call(SUB)
Call a sub
$Function VOID bad_memory(SUB)
To test *WRONG* behavior
$Function SUB total_recall()
To test *WRONG* behavior
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