[Varnish] #1800: PRIV_TASK in a vmod object method leads to code that cannot be compiled/linked
Varnish
varnish-bugs at varnish-cache.org
Sun Oct 11 23:52:42 CEST 2015
#1800: PRIV_TASK in a vmod object method leads to code that cannot be
compiled/linked
--------------------+--------------------
Reporter: geoff | Owner:
Type: defect | Status: new
Priority: normal | Milestone: Later
Component: vmod | Version: 4.1.0
Severity: normal | Resolution:
Keywords: |
--------------------+--------------------
Comment (by geoff):
OK, I've attached a patch to demonstrate the problem, which matches the
problem with my own VMOD.
The patch adds these two methods to the object "obj" in vmod debug:
{{{
$Method VOID .task_set(PRIV_TASK, INT)
$Method INT .task_get(PRIV_TASK, INT fallback=-1)
}}}
Set an integer in task scope, and retrieve it in the same scope.
m00000.vtc tests it:
{{{
sub vcl_init {
new foo = debug.obj("foo");
}
sub vcl_deliver {
# ...
foo.task_set(4711);
set resp.http.task = foo.task_get();
}
}}}
The generated code fails to compile with this message:
{{{
**** v1 0.2 CLI RX| Message from C-compiler:\n
**** v1 0.2 CLI RX| vgc.c: In function
\xe2\x80\x98VGC_function_vcl_deliver\xe2\x80\x99:\n
**** v1 0.2 CLI RX| vgc.c:1352:29: error:
\xe2\x80\x98VGC_vmod_foo\xe2\x80\x99 undeclared (first use in this
function)\n
**** v1 0.2 CLI RX| VRT_priv_task(ctx, &VGC_vmod_foo),\n
**** v1 0.2 CLI RX| ^\n
**** v1 0.2 CLI RX| vgc.c:1352:29: note: each undeclared identifier is
reported only once for each function it appears in\n
**** v1 0.2 CLI RX| Running C-compiler failed, exited with 1\n
**** v1 0.2 CLI RX| VCL compilation failed
---- v1 0.2 FAIL VCL does not compile
}}}
So please try to forget what I said about linking (duh), the problem is in
the generated C code. A symbol `VGC_vmod_<object name>` is used for the
priv object, but is not declared.
As I said above, the uncompilable code is the immediate problem, but it
also seems intuitive that object methods should be able to make use of
task scope -- in other words, rather than having the vmodtool generate an
error, it would be better to make PRIV_TASK possible in a method.
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1800#comment:3>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list