Mailing List Archive

#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code
#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal
C code
------------------------------------------+--------------------
Reporter: geoff | Type: defect
Status: new | Priority: high
Milestone: Later | Component: vmod
Version: trunk | Severity: major
Keywords: vmod,object,enum,string_list |
------------------------------------------+--------------------
If the signature of an object constructor specifies an ENUM followed by a
STRING_LIST, then illegal C code is emitted as the translation of VCL that
uses it in "new". This has been tested against current trunk (as of
today).

The patch that I'll be attaching demonstrates the problem:

{{{
$ ./varnishtest -i tests/m00000.vtc
[...]
**** v1 0.7 CLI RX| Message from C-compiler:\n
**** v1 0.7 CLI RX| vgc.c:1081:8: error: unknown type name
\xe2\x80\x98STRING_LIST\xe2\x80\x99\n
**** v1 0.7 CLI RX| static STRING_LIST *vo_list;\n
**** v1 0.7 CLI RX| ^\n
**** v1 0.7 CLI RX| vgc.c: In function
\xe2\x80\x98VGC_function_vcl_init\xe2\x80\x99:\n
**** v1 0.7 CLI RX| vgc.c:1325:44: error: passing argument 2 of
\xe2\x80\x98Vmod_debug_Func.enum_list__init\xe2\x80\x99 from incompatible
pointer type [-Werror]\n
**** v1 0.7 CLI RX| Vmod_debug_Func.enum_list__init(ctx,
&vo_list, "list",\n
**** v1 0.7 CLI RX| ^\n
**** v1 0.7 CLI RX| vgc.c:1325:44: note: expected \xe2\x80\x98struct
vmod_debug_enum_list **\xe2\x80\x99 but argument is of type
\xe2\x80\x98int **\xe2\x80\x99\n
**** v1 0.7 CLI RX| vgc.c: In function
\xe2\x80\x98VGC_Discard\xe2\x80\x99:\n
**** v1 0.7 CLI RX| vgc.c:1571:31: error: expected identifier or
\xe2\x80\x98(\xe2\x80\x99 before \xe2\x80\x98&\xe2\x80\x99 token\n
**** v1 0.7 CLI RX| [3 lines truncated]\n
**** v1 0.7 CLI RX| Running C-compiler failed, exited with 1\n
**** v1 0.7 CLI RX| VCL compilation failed
[...]
}}}

The sequences `\xe2\x80\x98` and `\xe2\x80\x99` are hex encodings of
Unicode open and close quotation marks, which the compiler is emitting on
my terminal for some reason.

So the compiler is saying that it encountered the declaration `static
STRING_LIST *vo_list;`, which I suspect was emitted by `parse_new()` in
`vcc_action.c` (line 216). I believe that can't ever be right, since a
STRING_LIST should always be turned into `const char *, ...`.

This problem apparently *only* happens with this combination: constructor,
ENUM and STRING_LIST. I get no problems with any of the following:

* ENUM followed by STRING_LIST in a VMOD function.
* STRING_LIST by itself in an object constructor
* INT followed by STRING_LIST in a constructor
* STRING followed by a STRING_LIST in a constructor

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1844>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code [ In reply to ]
#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal
C code
------------------------------------------+--------------------
Reporter: geoff | Owner:
Type: defect | Status: new
Priority: high | Milestone: Later
Component: vmod | Version: trunk
Severity: major | Resolution:
Keywords: vmod,object,enum,string_list |
------------------------------------------+--------------------

Comment (by fgsch):

Proposed patch attached.

I think this is enough but we could check for "struct".

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1844#comment:1>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code [ In reply to ]
#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal
C code
------------------------------------------+--------------------
Reporter: geoff | Owner:
Type: defect | Status: new
Priority: high | Milestone: Later
Component: vmod | Version: trunk
Severity: major | Resolution:
Keywords: vmod,object,enum,string_list |
------------------------------------------+--------------------

Comment (by geoff):

The patch works for me -- my own patch above for the Varnish tree runs
without an error, and the VMOD I was working on now gets past the
C-compile step.

Can't say if the check for "struct" is necessary.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1844#comment:2>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code [ In reply to ]
#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal
C code
------------------------------------------+--------------------
Reporter: geoff | Owner:
Type: defect | Status: new
Priority: high | Milestone: Later
Component: vmod | Version: trunk
Severity: major | Resolution:
Keywords: vmod,object,enum,string_list |
------------------------------------------+--------------------

Comment (by fgsch):

Just to clarify, this is a backward compatible approach.

In the long run we might want to revisit how we deal with ENUMs in
general.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1844#comment:3>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code [ In reply to ]
#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal
C code
------------------------------------------+--------------------
Reporter: geoff | Owner:
Type: defect | Status: new
Priority: high | Milestone: Later
Component: vmod | Version: trunk
Severity: major | Resolution:
Keywords: vmod,object,enum,string_list |
------------------------------------------+--------------------

Comment (by geoff):

I agree, the way ENUMs work now is kludgy. But we'll need the bugfix for
the time being.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1844#comment:4>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code [ In reply to ]
#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal
C code
-------------------------------------+-------------------------------------
Reporter: geoff | Owner: Federico G. Schwindt
Type: defect | <fgsch@…>
Priority: high | Status: closed
Component: vmod | Milestone: Later
Severity: major | Version: trunk
Keywords: | Resolution: fixed
vmod,object,enum,string_list |
-------------------------------------+-------------------------------------
Changes (by Federico G. Schwindt <fgsch@…>):

* owner: => Federico G. Schwindt <fgsch@…>
* status: new => closed
* resolution: => fixed


Comment:

In [84a2903805580973c59635bacb99df5da901c02c]:
{{{
#!CommitTicketReference repository=""
revision="84a2903805580973c59635bacb99df5da901c02c"
Correct ENUM handling in object constructors

Discussed with phk@. Fix confirmed by geoff@.

Fixes #1844.
}}}

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1844#comment:5>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code [ In reply to ]
#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal
C code
-------------------------------------+-------------------------------------
Reporter: geoff | Owner: Federico G. Schwindt
Type: defect | <fgsch@…>
Priority: high | Status: closed
Component: vmod | Milestone: Later
Severity: major | Version: trunk
Keywords: | Resolution: fixed
vmod,object,enum,string_list |
-------------------------------------+-------------------------------------

Comment (by geoff):

I can confirm that the VMOD I'm currently working on, which has this kind
of declaration, has no problems in a build against master with this fix.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1844#comment:6>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code [ In reply to ]
#1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal
C code
-------------------------------------+-------------------------------------
Reporter: geoff | Owner: Federico G. Schwindt
Type: defect | <fgsch@…>
Priority: high | Status: closed
Component: vmod | Milestone: Later
Severity: major | Version: trunk
Keywords: | Resolution: fixed
vmod,object,enum,string_list |
-------------------------------------+-------------------------------------

Comment (by Lasse Karstensen <lkarsten@…>):

In [6d7edfce44476a0f078476570b689d3d335b0aed]:
{{{
#!CommitTicketReference repository=""
revision="6d7edfce44476a0f078476570b689d3d335b0aed"
Correct ENUM handling in object constructors

Discussed with phk@. Fix confirmed by geoff@.

Fixes #1844.
}}}

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1844#comment:7>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs