[Varnish] #1844: VMODs: ENUM followed by STRING_LIST in an object constructor causes illegal C code

Varnish varnish-bugs at varnish-cache.org
Mon Jan 18 22:22:43 CET 2016


#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



More information about the varnish-bugs mailing list