• Geoff Simmons's avatar
    Breaking changes to invoke VCL failure for "can't happen" errors. · c70e410a
    Geoff Simmons authored
    Up to now we have emitted sentinel values for this class of errors,
    a relic of the time before VCL failure was introduced, when the VMOD
    was first developed. This may lead to fatal errors going unnoticed.
    These are the sorts of errors that should fail fast in development
    and testing, and never make it into production.
    
    We were already using VCL failure for the integer() method, since
    there is no sentinel integer.
    
    VCL failure is now invoked for these errors:
    
    - any regex compilation failure
    
    - all out of workspace errors
    
    - compile() or add() called in any VCL subroutine besides vcl_init
    
    - match() called for a set that was not compiled
    
    - failures reported by the RE2 lib for: match(), backref(),
      namedref(), the rewrite operations (sub, suball and extract),
      cost(), quotemeta()
    
    - numeric index reference for a set object (n parameter) that is out
      of range (greater than the number of patterns in the set)
    
    - functions and methods that require a previous successful match
      operation (with information stored in priv_task) when there was no
      prior match, or the previous macth failed.
    
    - use of select=UNIQUE when more than one pattern in a set matched
    
    - numeric (by index) or "associative" (after match) retrieval of an
      object for a set when no such object was saved in the constructor:
      strings, backends, regexen, etc
    
    - any of the following are undefined (NULL): fallbacks; patterns for
      regex functions (which are compiled at runtime); the text and
      rewrite parameters for the rewrite operations; name parameter
      for namedrefs
    
    - also if the named parameter for namedrefs is the empty string
    
    - backref number out of range (greater than the number of backrefs)
    
    - backref or namedref attempted without a prior match
    
    - backref or namedref when never_capture=true in the contructor
    
    - low-level failures reported by RE2 (eg cannot determine the number
      of backref groups). Most of these are possible, since the call
      returns an error status, but I have never seen them happen.
    
    VTC tests have been revised for the new error handling, which changes
    quite a bit in this commit.
    
    While we're here, use backend None in the tests where appropriate.
    Note that "bad_ip" backends are still necessary to test methods and
    functions that retrieve backends (numeric or associative references
    for sets).
    
    Error reporting is now done with VCL_fail(), so we get rid of the
    errmsg() function, and with it the re2.c source (since that was all
    there was in re2.c).
    c70e410a
README.md 63.8 KB