Giter Club home page Giter Club logo

libvmod-var's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libvmod-var's Issues

Segfault when doing var.set() with an unset header

Hello,

I'm getting a segfault when doing the following things:

unset req.http.Cookie;
var.set("name", req.http.Cookie);

Maybe it's better to somehow handle unset headers instead of a segfault.

Thanks in advance.

Segfault in vcl_backend_response

Hi,

I get segfault as soon as I use libvmod-var in vcl_backend_response with Varnish 4.0.0.

Default VCL with just changing this:

sub vcl_backend_response {
  var.set("foo", "bar");
}

Gives this:

kernel: varnishd[31186]: segfault at 18 ip 00007fa2431fc28f sp 00007fa2420ce170 error 4 in libvmod_var.so[7fa2431fb000+3000]
kernel: [81589.491201] varnishd[31186]: segfault at 18 ip 00007fa2431fc28f sp 00007fa2420ce170 error 4 in libvmod_var.so[7fa2431fb000+3000]

Doing the same in vcl_recv works fine.

Crash in vcl_recv when setting up variables in subroutine

This crash happens after 2-3 requests.

Startup command:

/usr/local/sbin/varnishd -P /var/run/varnishd.pid -a :6081 -T localhost:6082 -p vcl_dir=/etc/varnish -p http_req_hdr_len=32768 -p http_req_size=65536 -p workspace_backend=252144 -p workspace_client=252144 -f /etc/varnish/test.vcl -S /etc/varnish/secret -s malloc,256m -d

VCL:

vcl 4.0;

import std;
import var;
import digest;
import cookie;

backend default {
    .host = "192.168.56.1";
    .port = "80";
}

sub set_var {
    var.set_duration("cacheError", 2s);
    var.set_int("isDevel", 1);
}

sub vcl_recv {
    call set_var;

    set req.backend_hint = default;

    return(pass);
}
Assert error in vh_get_var(), vmod_var.c line 60:
  Condition((v)->magic == 0x8A21A651) not true.
thread = (cache-worker)
ident = Linux,2.6.32-5-amd64,x86_64,-smalloc,-smalloc,-hcritbit,epoll
Backtrace:
  0x43cf7d: pan_backtrace+0x19
  0x43d28d: pan_ic+0x1e8
  0x7fab258f3082: /usr/local/lib/varnish/vmods/libvmod_var.so(+0x1082) [0x7fab258f3082]
  0x7fab258f3a96: /usr/local/lib/varnish/vmods/libvmod_var.so(+0x1a96) [0x7fab258f3a96]
  0x7fab258f3bd1: /usr/local/lib/varnish/vmods/libvmod_var.so(vmod_set_duration+0x31) [0x7fab258f3bd1]
  0x7fab25cfee06: ./vcl.cmLlBEzo.so(VGC_function_set_var+0x26) [0x7fab25cfee06]
  0x7fab25cff576: ./vcl.cmLlBEzo.so(VGC_function_vcl_recv+0x16) [0x7fab25cff576]
  0x44d2c4: vcl_call_method+0x450
  0x44d456: VCL_recv_method+0x125
  0x443cd0: cnt_recv+0x5c1
req = 0x7fab20af7030 {
  sp = 0x1c051c0, vxid = 1073741828,  step = R_STP_RECV,
  req_body = R_BODY_NONE,
  restarts = 0, esi_level = 0
  sp = 0x1c051c0 {
    fd = 12, vxid = 1,
    client = 192.168.56.1 61069,
    step = S_STP_WORKING,
  },
  worker = 0x7fab21269c50 {
    ws = 0x7fab21269e68 {
      id = "wrk",
      {s,f,r,e} = {0x7fab21269410,0x7fab21269410,(nil),+2048},
    },
  VCL::method = RECV,
  VCL::return = abandon,
  },
  ws = 0x7fab20af71c8 {
    id = "req",
    {s,f,r,e} = {0x7fab20af9020,+576,(nil),+243968},
  },
  http[req] = {
    ws = 0x7fab20af71c8[req]
      "GET",
      "/favicon.ico",
      "HTTP/1.1",
      "Host: *DELETED*",
      "Connection: keep-alive",
      "Pragma: no-cache",
      "Cache-Control: no-cache",
      "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
      "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36",
      "Accept-Encoding: gzip,deflate,sdch",
      "Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4",
      "Cookie: *DELETED*",
      "X-Forwarded-For: 192.168.56.1",
  },
  vcl = {
    srcname = {
      "input",
      "Builtin",
    },
  },
},

Crash using global_get() on vcl_init{}

Via @espebra via #9:

*** v1 1.9 debug| Child (8109) died signal=6 (core dumped)\n
*** v1 1.9 debug| Child (8109) Panic message:\n
*** v1 1.9 debug| Assert error in WS_Assert(), cache/cache_ws.c line 41:\n
*** v1 1.9 debug| Condition((ws) != NULL) not true.\n
*** v1 1.9 debug| thread = (cache-main)\n
*** v1 1.9 debug| version = varnish-trunk revision 34360fd\n
*** v1 1.9 debug| ident = Linux,4.1.0-1-amd64,x86_64,-jnone,-smalloc,-smalloc,-hcritbit,epoll\n
*** v1 1.9 debug| Backtrace:\n
*** v1 1.9 debug| 0x44dab0: pan_backtrace+0x20\n
*** v1 1.9 debug| 0x44d8b3: pan_ic+0x363\n
*** v1 1.9 debug| 0x47766f: WS_Assert+0x4f\n
*** v1 1.9 debug| 0x4782ec: WS_Copy+0x1c\n
*** v1 1.9 debug| 0x7fd2a41232fe: libvmod_var.so(vmod_global_get+0x1ce) [0x7fd2a41232fe]\n
*** v1 1.9 debug| 0x7fd2a43a7ff8: vgc.so(VGC_function_vcl_init+0x48) [0x7fd2a43a7ff8]\n
*** v1 1.9 debug| 0x7fd2a43a8599: vgc.so(+0x2599) [0x7fd2a43a8599]\n
*** v1 1.9 debug| 0x465888: VCL_Load+0x308\n
*** v1 1.9 debug| 0x464819: ccf_config_load+0xd9\n
*** v1 1.9 debug| 0x7fd2ab78b7e4: libvarnish.so(+0xa7e4) [0x7fd2ab78b7e4]\n
*** v1 1.9 debug| \n
*** v1 1.9 debug| \n

Testcase:

varnishtest "Test global_get in vcl_init"

server s1 {
       rxreq
       txresp
} -start

varnish v1 -vcl+backend {
        import var from "${vmod_topbuild}/src/.libs/libvmod_var.so";

        sub vcl_init {
                var.global_set("foo", "bar");
                if (var.global_get("foo") == "bar") {
                        var.global_set("foo", "baz");
                }
        }

        sub vcl_deliver {
                set resp.http.x-foo = var.global_get("foo");
        }
} -start

client c1 {
        txreq -url "/"
        rxresp
        expect resp.http.x-foo == "baz"
} -start

Crashes on pipelined requests

get_vh uses the vxid of the session instead of the request, and thus we attempt to use the state from a now cleared workspace on the subsequent request.

A workaround is to issue a var.clear() prior to any var.set()/var.get() invocation

Related: See @rezan's comment in #10

This bug only applies to branch 4.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.