From nils.goroll at uplex.de Mon Jul 3 08:55:09 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 08:55:09 +0000 (UTC) Subject: [master] bada81bf6 Avoid hang when child does not come up, add startup_timeout Message-ID: <20230703085509.D30AC105DCA@lists.varnish-cache.org> commit bada81bf65c69a0120f57e3b2742015d052412fb Author: Nils Goroll Date: Fri Jun 16 21:50:31 2023 +0200 Avoid hang when child does not come up, add startup_timeout When a child did not come up within cli_timeout, varnishd startup would hang indefinitely. We add startup_timeout specifically for child startup. To facilitate the transition, we use the maximum of cli_timeout and start_timeout (suggested by Dridi, thank you) and add a tip if startup_timeout is not used. We avoid the previous harsh exit(1), primarily to make the vtc_varnish facility work. The test case uses both vtc_varnish and vtc_process to exercise the different code paths for implicit startup vs. cli "start". Fixes #3940 diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 28e7b4570..188cad7bc 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -90,6 +90,7 @@ static struct vlu *child_std_vlu; static struct vsb *child_panic = NULL; static void mgt_reap_child(void); +static int kill_child(void); /*===================================================================== * Panic string evacuation and handling @@ -302,12 +303,14 @@ child_poker(const struct vev *e, int what) static void mgt_launch_child(struct cli *cli) { - pid_t pid, pidr; + pid_t pid; unsigned u; char *p; struct vev *e; int i, cp[2]; struct rlimit rl[1]; + vtim_dur dstart; + vtim_mono t0; if (child_state != CH_STOPPED && child_state != CH_DIED) return; @@ -436,15 +439,23 @@ mgt_launch_child(struct cli *cli) AN(child_std_vlu); /* Wait for cache/cache_cli.c::CLI_Run() to check in */ - if (VCLI_ReadResult(child_cli_in, &u, NULL, mgt_param.cli_timeout)) { + dstart = vmax(mgt_param.startup_timeout, mgt_param.cli_timeout); + t0 = VTIM_mono(); + if (VCLI_ReadResult(child_cli_in, &u, NULL, dstart)) { + int bstart = mgt_param.startup_timeout >= mgt_param.cli_timeout; assert(u == CLIS_COMMS); - pidr = waitpid(pid, &i, 0); - assert(pidr == pid); - do { - i = VLU_Fd(child_std_vlu, child_output); - } while (i == 0); - MGT_Complain(C_ERR, "Child failed on launch"); - exit(1); // XXX Harsh ? + if (VTIM_mono() - t0 < dstart) + mgt_launch_err(cli, u, "Child failed on launch "); + else + mgt_launch_err(cli, u, "Child failed on launch " + "within %s_timeout=%.2fs%s", + bstart ? "startup" : "cli", dstart, + bstart ? "" : " (tip: set startup_timeout)"); + child_pid = pid; + kill_child(); + mgt_reap_child(); + child_state = CH_STOPPED; + return; } else { assert(u == CLIS_OK); fprintf(stderr, "Child launched OK\n"); diff --git a/bin/varnishtest/tests/p00000.vtc b/bin/varnishtest/tests/p00000.vtc index 8b4b6493d..e7a4219b4 100644 --- a/bin/varnishtest/tests/p00000.vtc +++ b/bin/varnishtest/tests/p00000.vtc @@ -9,7 +9,8 @@ process p1 -dump { process p1 -expect-text 0 0 {to launch} process p1 -write "start\n" process p1 -expect-text 0 0 {-spersistent has been deprecated} -process p1 -wait +process p1 -write "quit\n" +process p1 -expect-exit 0x20 -wait server s1 { rxreq diff --git a/bin/varnishtest/tests/r03940.vtc b/bin/varnishtest/tests/r03940.vtc new file mode 100644 index 000000000..1213330c5 --- /dev/null +++ b/bin/varnishtest/tests/r03940.vtc @@ -0,0 +1,45 @@ +varnishtest "test startup_timeout vs. stevedore init / open" + +# we test with vtc_varnish and vtc_process because of different code +# paths in mgr for implicit start vs. cli start + +#### +# startup_timeout used, delay in stevedore init +varnish v1 -arg "-sdebug=debug,dinit=5s -pstartup_timeout=3s -pcli_timeout=2s" \ + -arg "-p feature=+no_coredump" \ + -vcl "backend none none;" +varnish v1 -cliexpect \ + "Child failed on launch within startup_timeout=3.00s" \ + "start" +varnish v1 -expectexit 0x40 + +process p1 { varnishd \ + -sdebug=debug,dinit=5s \ + -pstartup_timeout=3s -pcli_timeout=2s \ + -n ${tmpdir}/p1 -a :0 -b none 2>&1 } -start +process p1 -expect-exit 0x2 -wait +process p1 -expect-text 0 0 \ + "Child failed on launch within startup_timeout=3.00s" + +#### +# cli_timeout used, delay in stevedore open + +varnish v2 -arg "-sdebug=debug,dopen=5s -pstartup_timeout=2s -pcli_timeout=3s" \ + -arg "-p feature=+no_coredump" \ + -vcl "backend none none;" +varnish v2 -cliexpect \ + "launch within cli_timeout=3.00s .tip: set startup_" \ + "start" +varnish v2 -cliok "panic.clear" +varnish v2 -expectexit 0x40 + +process p2 { varnishd \ + -sdebug=debug,dopen=5s \ + -pstartup_timeout=2s -pcli_timeout=3s \ + -n ${tmpdir}/p2 -a :0 -b none} -start +process p2 -expect-exit 0x2 -wait + +# expect-text does not work here because the panic info pushes the +# error out of the emulated terminal's view. +# And I do not want to rely on any x lines to be enough +shell {grep -q "launch within cli_timeout=3.00s (tip: set startup_" ${p2_err}} diff --git a/bin/varnishtest/tests/s00003.vtc b/bin/varnishtest/tests/s00003.vtc index d1077dd93..f186d8956 100644 --- a/bin/varnishtest/tests/s00003.vtc +++ b/bin/varnishtest/tests/s00003.vtc @@ -47,13 +47,13 @@ varnish v1 -cliok "ban obj.http.date ~ ." process p1 { varnishd -sTransient=file,${tmpdir}/foo,xxx -blocalhost -a:0 -n ${tmpdir} 2>&1 -} -expect-exit 255 -dump -start -expect-text 0 0 "Invalid number" -wait -screen_dump +} -expect-exit 0x2 -dump -start -expect-text 0 0 "Invalid number" -wait -screen_dump process p1 { varnishd -sTransient=file,${tmpdir}/foo,10M,xxx -blocalhost -a:0 -n ${tmpdir} 2>&1 -} -expect-exit 255 -dump -start -expect-text 0 0 "granularity" -wait -screen_dump +} -expect-exit 0x2 -dump -start -expect-text 0 0 "granularity" -wait -screen_dump process p1 { varnishd -sTransient=file,${tmpdir}/foo,10m,,foo -blocalhost -a:0 -n ${tmpdir} 2>&1 -} -expect-exit 255 -dump -start -expect-text 0 0 "invalid advice" -wait +} -expect-exit 0x2 -dump -start -expect-text 0 0 "invalid advice" -wait diff --git a/include/tbl/params.h b/include/tbl/params.h index 8a066361f..83054eef3 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -335,6 +335,18 @@ PARAM_SIMPLE( "Timeout for the child's replies to CLI requests." ) +PARAM_SIMPLE( + /* name */ startup_timeout, + /* type */ timeout, + /* min */ "0.000", + /* max */ NULL, + /* def */ "0.000", + /* units */ "seconds", + /* descr */ + "Alternative timeout for the initial worker process startup.\n" + "If cli_timeout is longer than startup_timeout, it is used instead." +) + PARAM_SIMPLE( /* name */ clock_skew, /* type */ uint, From nils.goroll at uplex.de Mon Jul 3 08:55:09 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 08:55:09 +0000 (UTC) Subject: [master] aa23821f6 SQUASHME: Address Dridis nitpicks Message-ID: <20230703085509.EBAE2105DCD@lists.varnish-cache.org> commit aa23821f6ff703894d58853377f377b6babc6d4d Author: Nils Goroll Date: Thu Jun 29 16:12:08 2023 +0200 SQUASHME: Address Dridis nitpicks diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 188cad7bc..53918825b 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -310,6 +310,7 @@ mgt_launch_child(struct cli *cli) int i, cp[2]; struct rlimit rl[1]; vtim_dur dstart; + int bstart; vtim_mono t0; if (child_state != CH_STOPPED && child_state != CH_DIED) @@ -439,10 +440,10 @@ mgt_launch_child(struct cli *cli) AN(child_std_vlu); /* Wait for cache/cache_cli.c::CLI_Run() to check in */ - dstart = vmax(mgt_param.startup_timeout, mgt_param.cli_timeout); + bstart = mgt_param.startup_timeout >= mgt_param.cli_timeout; + dstart = bstart ? mgt_param.startup_timeout : mgt_param.cli_timeout; t0 = VTIM_mono(); if (VCLI_ReadResult(child_cli_in, &u, NULL, dstart)) { - int bstart = mgt_param.startup_timeout >= mgt_param.cli_timeout; assert(u == CLIS_COMMS); if (VTIM_mono() - t0 < dstart) mgt_launch_err(cli, u, "Child failed on launch "); diff --git a/bin/varnishtest/tests/r03940.vtc b/bin/varnishtest/tests/r03940.vtc index 1213330c5..febc602ec 100644 --- a/bin/varnishtest/tests/r03940.vtc +++ b/bin/varnishtest/tests/r03940.vtc @@ -16,8 +16,8 @@ varnish v1 -expectexit 0x40 process p1 { varnishd \ -sdebug=debug,dinit=5s \ -pstartup_timeout=3s -pcli_timeout=2s \ - -n ${tmpdir}/p1 -a :0 -b none 2>&1 } -start -process p1 -expect-exit 0x2 -wait + -n ${tmpdir}/p1 -a :0 -b none 2>&1 +} -expect-exit 0x2 -run process p1 -expect-text 0 0 \ "Child failed on launch within startup_timeout=3.00s" @@ -36,8 +36,8 @@ varnish v2 -expectexit 0x40 process p2 { varnishd \ -sdebug=debug,dopen=5s \ -pstartup_timeout=2s -pcli_timeout=3s \ - -n ${tmpdir}/p2 -a :0 -b none} -start -process p2 -expect-exit 0x2 -wait + -n ${tmpdir}/p2 -a :0 -b none +} -expect-exit 0x2 -run # expect-text does not work here because the panic info pushes the # error out of the emulated terminal's view. From nils.goroll at uplex.de Mon Jul 3 10:48:06 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 10:48:06 +0000 (UTC) Subject: [master] 07b079a71 Polish: Move heritage.proc_vsmw initialization a bit Message-ID: <20230703104806.8D872109951@lists.varnish-cache.org> commit 07b079a71887c5497166650140bfe7cd3c742f44 Author: Nils Goroll Date: Mon Jul 3 12:29:00 2023 +0200 Polish: Move heritage.proc_vsmw initialization a bit printf debugging showed that the initial VSMW_New() call did not go through vsm_vsmw_lock() / vsm_vsmw_unlock() simply because the function pointers were not initialized yet. This patch moves the init just after their initialization. child_main() was previously called right after VSMW_New(), and VSM_Init() is almost the first thing which child_main() calls, so this move is mostly cosmetic. Seen staring at #3948 diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index fd47d6bfa..e1ae6e286 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -662,6 +662,9 @@ VSM_Init(void) vsmw_lock = vsm_vsmw_lock; vsmw_unlock = vsm_vsmw_unlock; + heritage.proc_vsmw = VSMW_New(heritage.vsm_fd, 0640, "_.index"); + AN(heritage.proc_vsmw); + VSC_C_main = VSC_main_New(NULL, NULL, ""); AN(VSC_C_main); diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 53918825b..742525fa5 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -402,9 +402,6 @@ mgt_launch_child(struct cli *cli) VJ_subproc(JAIL_SUBPROC_WORKER); - heritage.proc_vsmw = VSMW_New(heritage.vsm_fd, 0640, "_.index"); - AN(heritage.proc_vsmw); - /* * We pass these two params because child_main needs them * well before it has found its own param struct. From dridi.boukelmoune at gmail.com Mon Jul 3 14:04:06 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 3 Jul 2023 14:04:06 +0000 (UTC) Subject: [master] 180cacf17 vsc: Create a pool group in the main segment Message-ID: <20230703140406.9CC3C113004@lists.varnish-cache.org> commit 180cacf17127ecbf12e6f4819bdf7ca3e2ff7d6e Author: Dridi Boukelmoune Date: Wed Jun 28 11:06:17 2023 +0200 vsc: Create a pool group in the main segment diff --git a/lib/libvsc/VSC_main.vsc b/lib/libvsc/VSC_main.vsc index 46655ca72..a4049fccb 100644 --- a/lib/libvsc/VSC_main.vsc +++ b/lib/libvsc/VSC_main.vsc @@ -10,7 +10,7 @@ .. varnish_vsc_begin:: main :oneliner: Main counters :order: 10 - :sumfunction: wrk_wrk wrk + :sumfunction: wrk_wrk wrk pool .. varnish_vsc:: summs :level: debug @@ -325,18 +325,21 @@ lack of resources. .. varnish_vsc:: sess_queued + :group: pool :oneliner: Sessions queued for thread Number of times session was queued waiting for a thread. See also parameter thread_queue_limit. .. varnish_vsc:: sess_dropped + :group: pool :oneliner: Sessions dropped for thread Number of times an HTTP/1 session was dropped because the queue was too long already. See also parameter thread_queue_limit. .. varnish_vsc:: req_dropped + :group: pool :oneliner: Requests dropped Number of times an HTTP/2 stream was refused because the queue was From dridi.boukelmoune at gmail.com Mon Jul 3 14:04:06 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 3 Jul 2023 14:04:06 +0000 (UTC) Subject: [master] c6c4915a2 wrk: Track pool statistics separately Message-ID: <20230703140406.BBAA6113007@lists.varnish-cache.org> commit c6c4915a2fbf36afcdc8f745be53315f0d3e791c Author: Dridi Boukelmoune Date: Wed Jun 28 11:07:09 2023 +0200 wrk: Track pool statistics separately This makes obvious what is used for statistics purposes and what is used to maintain the pool queue. In particular, the pool::nqueued field has nothing to do with pool::ndequeued. diff --git a/bin/varnishd/cache/cache_pool.h b/bin/varnishd/cache/cache_pool.h index 207e275b1..11bcfbd11 100644 --- a/bin/varnishd/cache/cache_pool.h +++ b/bin/varnishd/cache/cache_pool.h @@ -51,10 +51,8 @@ struct pool { struct taskhead queues[TASK_QUEUE_RESERVE]; unsigned nthr; unsigned lqueue; - uintmax_t sdropped; - uintmax_t rdropped; - uintmax_t nqueued; uintmax_t ndequeued; + struct VSC_main_pool stats[1]; struct VSC_main_wrk *a_stat; struct VSC_main_wrk *b_stat; diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index cc306a1e8..fe4c650b5 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -343,15 +343,20 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio) } else if (!TASK_QUEUE_LIMITED(prio) || pp->lqueue + pp->nthr < cache_param->wthread_max + cache_param->wthread_queue_limit) { - pp->nqueued++; + pp->stats->sess_queued++; pp->lqueue++; VTAILQ_INSERT_TAIL(&pp->queues[prio], task, list); PTOK(pthread_cond_signal(&pp->herder_cond)); } else { + /* NB: This is counter-intuitive but when we drop a REQ + * task, it is an HTTP/1 request and we effectively drop + * the whole session. It is otherwise an h2 stream with + * STR priority in which case we are dropping a request. + */ if (prio == TASK_QUEUE_REQ) - pp->sdropped++; + pp->stats->sess_dropped++; else - pp->rdropped++; + pp->stats->req_dropped++; retval = -1; } Lck_Unlock(&pp->mtx); @@ -651,10 +656,8 @@ pool_herder(void *priv) Lck_Lock(&pp->mtx); /* XXX: unsafe counters */ - VSC_C_main->sess_queued += pp->nqueued; - VSC_C_main->sess_dropped += pp->sdropped; - VSC_C_main->req_dropped += pp->rdropped; - pp->nqueued = pp->sdropped = pp->rdropped = 0; + VSC_main_Summ_pool(VSC_C_main, pp->stats); + memset(pp->stats, 0, sizeof pp->stats); wrk = NULL; pt = VTAILQ_LAST(&pp->idle_queue, taskhead); From dridi.boukelmoune at gmail.com Mon Jul 3 14:04:06 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 3 Jul 2023 14:04:06 +0000 (UTC) Subject: [master] ae3003479 wrk: Simplify condition Message-ID: <20230703140406.D6C9111300F@lists.varnish-cache.org> commit ae3003479d7d3d7ee8dda85f549b2aafefff4375 Author: Dridi Boukelmoune Date: Wed Jun 28 11:08:19 2023 +0200 wrk: Simplify condition diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index fe4c650b5..427ddafbf 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -193,7 +193,7 @@ wrk_addstat(const struct worker *wrk, const struct pool_task *tp, unsigned locke Lck_Unlock(&pp->mtx); } - return (tp == NULL ? 0 : 1); + return (tp != NULL); } void From dridi.boukelmoune at gmail.com Mon Jul 3 14:04:07 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 3 Jul 2023 14:04:07 +0000 (UTC) Subject: [master] bd443dd52 pool: Safely update pool statistics Message-ID: <20230703140407.4C4D711301A@lists.varnish-cache.org> commit bd443dd525654c3108ae57a1073dddf37dde8876 Author: Dridi Boukelmoune Date: Wed Jun 28 11:08:48 2023 +0200 pool: Safely update pool statistics diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 89d12b655..53d00a5b8 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -116,17 +116,27 @@ void v_matchproto_(task_func_t) pool_stat_summ(struct worker *wrk, void *priv) { struct VSC_main_wrk *src; + struct pool *pp; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->pool, POOL_MAGIC); + pp = wrk->pool; + CHECK_OBJ_NOTNULL(pp, POOL_MAGIC); AN(priv); src = priv; + Lck_Lock(&wstat_mtx); VSC_main_Summ_wrk(VSC_C_main, src); + + Lck_Lock(&pp->mtx); + VSC_main_Summ_pool(VSC_C_main, pp->stats); + Lck_Unlock(&pp->mtx); + memset(pp->stats, 0, sizeof pp->stats); + Lck_Unlock(&wstat_mtx); memset(src, 0, sizeof *src); - AZ(wrk->pool->b_stat); - wrk->pool->b_stat = src; + + AZ(pp->b_stat); + pp->b_stat = src; } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 427ddafbf..8803b5048 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -655,10 +655,6 @@ pool_herder(void *priv) t_idle = VTIM_real() - cache_param->wthread_timeout; Lck_Lock(&pp->mtx); - /* XXX: unsafe counters */ - VSC_main_Summ_pool(VSC_C_main, pp->stats); - memset(pp->stats, 0, sizeof pp->stats); - wrk = NULL; pt = VTAILQ_LAST(&pp->idle_queue, taskhead); if (pt != NULL) { diff --git a/bin/varnishtest/tests/c00124.vtc b/bin/varnishtest/tests/c00124.vtc new file mode 100644 index 000000000..2da09f139 --- /dev/null +++ b/bin/varnishtest/tests/c00124.vtc @@ -0,0 +1,116 @@ +varnishtest "rushed task queued" + +# thread reserve mitigation barrier +barrier b0 sock 2 + +# client ordering barrier +barrier b1 cond 3 + +# waitinglist barrier +barrier b2 cond 2 + +# thread starvation barrier +barrier b3 cond 3 + +server s1 { + rxreq + barrier b1 sync + barrier b3 sync + txresp +} -start + +server s2 { + rxreq + barrier b1 sync + barrier b2 sync + txresp -nolen -hdr "Transfer-Encoding: chunked" + chunkedlen 10 + barrier b3 sync + chunkedlen 0 +} -start + +varnish v1 -cliok "param.set thread_pools 1" +varnish v1 -cliok "param.set thread_pool_min 5" +varnish v1 -cliok "param.set thread_pool_max 5" +varnish v1 -cliok "param.set debug +syncvsl" +varnish v1 -cliok "param.set debug +waitinglist" + +varnish v1 -vcl+backend { + import vtc; + + sub vcl_recv { + if (req.http.server) { + # ensure both c1 and c2 got a thread + vtc.barrier_sync("${b0_sock}"); + } + } + + sub vcl_backend_fetch { + if (bereq.http.server == "s1") { + set bereq.backend = s1; + } else if (bereq.http.server == "s2") { + set bereq.backend = s2; + } + } +} -start + +# wait for all threads to be started +varnish v1 -expect threads == 5 + +# 2 threads +client c1 { + txreq -hdr "Cookie: foo" -hdr "server: s1" + rxresp +} -start + +# 2 threads +client c2 { + txreq -hdr "server: s2" + rxresp +} -start + +# ensure c1 and c2 fetch tasks are started +barrier b1 sync + +logexpect l1 -v v1 -g raw { + expect * 1007 Debug "on waiting list" +} -start + +logexpect l2 -v v1 -g raw { + expect * 1007 Debug "off waiting list" +} -start + +varnish v1 -expect sess_dropped == 0 +varnish v1 -expect sess_queued == 0 + +# At this point, we are thread-starved and c3 below will steal the +# acceptor thread. It will be queued before the acceptor task queues +# itself with a lower priority. +client c3 { + txreq + rxresp +} -start + +logexpect l1 -wait + +varnish v1 -expect sess_dropped == 0 +varnish v1 -expect sess_queued == 1 +varnish v1 -expect busy_sleep == 1 + +# Wake up c2, This will in turn trigger a waitinglist rush and wake up c3. +barrier b2 sync + +# The acceptor thread could have restarted on the newly available thread +# if it weren't for the thread pool reserve. For the same reason, c3's +# client task should be queued once woken up. +logexpect l2 -wait + +# let everyone loose +barrier b3 sync + +client c1 -wait +client c2 -wait +client c3 -wait + +varnish v1 -expect sess_dropped == 0 +varnish v1 -expect sess_queued == 2 From nils.goroll at uplex.de Mon Jul 3 14:54:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 14:54:05 +0000 (UTC) Subject: [master] c09623784 Polish confusing output Message-ID: <20230703145405.7137E115067@lists.varnish-cache.org> commit c096237845e28a05f04fb19c6d29fd384f498b78 Author: Nils Goroll Date: Mon Jul 3 16:24:20 2023 +0200 Polish confusing output as seen in varnishtest: *** v1 debug|Error: Child (0) not dying, killingChild (74042) died signal=6 diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 742525fa5..7edd7a844 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -566,7 +566,8 @@ mgt_reap_child(void) (void)usleep(100000); } if (r == 0) { - VSB_printf(vsb, "Child (%jd) not dying, killing", (intmax_t)r); + VSB_printf(vsb, "Child (%jd) not dying (waitpid = %jd)," + " killing\n", (intmax_t)child_pid, (intmax_t)r); /* Kick it Jim... */ (void)kill_child(); From nils.goroll at uplex.de Mon Jul 3 14:54:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 14:54:05 +0000 (UTC) Subject: [master] 60e16f2f9 Listen to dying child Message-ID: <20230703145405.8397511506A@lists.varnish-cache.org> commit 60e16f2f91ca4b5fc4d151e3c78e96bdf26323bc Author: Nils Goroll Date: Mon Jul 3 16:51:34 2023 +0200 Listen to dying child An r3940 vtest failure on freebsd seems to suggest that the child does not terminate while blocking in a write. *** v1 debug|Error: Child (74042) Panic at: Mon, 03 Jul 2023 13:40:40 GMT *** v1 debug|Assert error in CLI_Run(), cache/cache_cli.c line 102: *** v1 debug| Condition((VCLI_WriteResult(heritage.cli_out, CLIS_OK, \"Ready\")) == 0) not true. This might need another iteration. diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 7edd7a844..6b7c2b0e7 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -558,8 +558,10 @@ mgt_reap_child(void) vsb = VSB_new_auto(); XXXAN(vsb); + (void)VFIL_nonblocking(child_output); /* Wait for child to die */ for (i = 0; i < mgt_param.cli_timeout * 10; i++) { + (void)child_listener(NULL, VEV__RD); r = waitpid(child_pid, &status, WNOHANG); if (r == child_pid) break; From nils.goroll at uplex.de Mon Jul 3 15:59:07 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 15:59:07 +0000 (UTC) Subject: [master] 6b7f63293 Stabilize r03940.vtc Message-ID: <20230703155907.A284F118570@lists.varnish-cache.org> commit 6b7f63293940498152a7fb64a00e9a7851d27970 Author: Nils Goroll Date: Mon Jul 3 17:56:30 2023 +0200 Stabilize r03940.vtc I do not understand how to avoid the child panicking while it is being killed for timeout. And removing the AZ() for this case only is not a good idea. *** v1 debug|Error: Child (36277) not dying (waitpid = 0), killing *** v1 debug|Child (36277) died signal=6 *** v1 debug|Error: Child (36277) Panic at: Mon, 03 Jul 2023 15:18:50 GMT *** v1 debug|Assert error in CLI_Run(), cache/cache_cli.c line 102: *** v1 debug| Condition((VCLI_WriteResult(heritage.cli_out, CLIS_OK, \"Ready\")) == 0) not true. diff --git a/bin/varnishtest/tests/r03940.vtc b/bin/varnishtest/tests/r03940.vtc index febc602ec..87c87fb79 100644 --- a/bin/varnishtest/tests/r03940.vtc +++ b/bin/varnishtest/tests/r03940.vtc @@ -18,8 +18,9 @@ process p1 { varnishd \ -pstartup_timeout=3s -pcli_timeout=2s \ -n ${tmpdir}/p1 -a :0 -b none 2>&1 } -expect-exit 0x2 -run -process p1 -expect-text 0 0 \ - "Child failed on launch within startup_timeout=3.00s" +# expect-text does not work if a panic info pushes the +# error out of the emulated terminal's view. +shell {grep -q "Child failed on launch within startup_timeout=3.00s" ${p1_err}} #### # cli_timeout used, delay in stevedore open @@ -39,7 +40,5 @@ process p2 { varnishd \ -n ${tmpdir}/p2 -a :0 -b none } -expect-exit 0x2 -run -# expect-text does not work here because the panic info pushes the -# error out of the emulated terminal's view. -# And I do not want to rely on any x lines to be enough +# see explanation of previous shell grep shell {grep -q "launch within cli_timeout=3.00s (tip: set startup_" ${p2_err}} From nils.goroll at uplex.de Mon Jul 3 16:27:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 16:27:05 +0000 (UTC) Subject: [master] 0c29ad8d1 Fix previous :/ Message-ID: <20230703162705.D1143119763@lists.varnish-cache.org> commit 0c29ad8d1143f857a81ac3033135efa0a56b4406 Author: Nils Goroll Date: Mon Jul 3 18:25:52 2023 +0200 Fix previous :/ diff --git a/bin/varnishtest/tests/r03940.vtc b/bin/varnishtest/tests/r03940.vtc index 87c87fb79..f6d7c609a 100644 --- a/bin/varnishtest/tests/r03940.vtc +++ b/bin/varnishtest/tests/r03940.vtc @@ -20,7 +20,7 @@ process p1 { varnishd \ } -expect-exit 0x2 -run # expect-text does not work if a panic info pushes the # error out of the emulated terminal's view. -shell {grep -q "Child failed on launch within startup_timeout=3.00s" ${p1_err}} +shell {grep -q "Child failed on launch within startup_timeout=3.00s" ${p1_out}} #### # cli_timeout used, delay in stevedore open From nils.goroll at uplex.de Mon Jul 3 19:18:09 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 19:18:09 +0000 (UTC) Subject: [master] 49d2b99dc r3940: wait for varnish instances Message-ID: <20230703191809.DCA7C11EBBD@lists.varnish-cache.org> commit 49d2b99dcfce707e1e03e7574bbd54656d16600b Author: Nils Goroll Date: Mon Jul 3 21:16:42 2023 +0200 r3940: wait for varnish instances Hopefully this should fix vtest errors on bsd/arm Thank you to phk for the quick help! diff --git a/bin/varnishtest/tests/r03940.vtc b/bin/varnishtest/tests/r03940.vtc index f6d7c609a..71211dde1 100644 --- a/bin/varnishtest/tests/r03940.vtc +++ b/bin/varnishtest/tests/r03940.vtc @@ -7,11 +7,12 @@ varnishtest "test startup_timeout vs. stevedore init / open" # startup_timeout used, delay in stevedore init varnish v1 -arg "-sdebug=debug,dinit=5s -pstartup_timeout=3s -pcli_timeout=2s" \ -arg "-p feature=+no_coredump" \ - -vcl "backend none none;" + -vcl "backend none none;" \ + -expectexit 0x40 varnish v1 -cliexpect \ "Child failed on launch within startup_timeout=3.00s" \ "start" -varnish v1 -expectexit 0x40 +varnish v1 -wait process p1 { varnishd \ -sdebug=debug,dinit=5s \ @@ -27,12 +28,13 @@ shell {grep -q "Child failed on launch within startup_timeout=3.00s" ${p1_out}} varnish v2 -arg "-sdebug=debug,dopen=5s -pstartup_timeout=2s -pcli_timeout=3s" \ -arg "-p feature=+no_coredump" \ - -vcl "backend none none;" + -vcl "backend none none;" \ + -expectexit 0x40 varnish v2 -cliexpect \ "launch within cli_timeout=3.00s .tip: set startup_" \ "start" varnish v2 -cliok "panic.clear" -varnish v2 -expectexit 0x40 +varnish v2 -wait process p2 { varnishd \ -sdebug=debug,dopen=5s \ From nils.goroll at uplex.de Mon Jul 3 19:43:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 19:43:05 +0000 (UTC) Subject: [master] 28c46ae9f r3940: make clear that the big quit is expected Message-ID: <20230703194305.9944A11F9B2@lists.varnish-cache.org> commit 28c46ae9f92f62dd233274b60448c02300667e2e Author: Nils Goroll Date: Mon Jul 3 21:25:29 2023 +0200 r3940: make clear that the big quit is expected diff --git a/bin/varnishtest/tests/r03940.vtc b/bin/varnishtest/tests/r03940.vtc index 71211dde1..b017adc5c 100644 --- a/bin/varnishtest/tests/r03940.vtc +++ b/bin/varnishtest/tests/r03940.vtc @@ -33,6 +33,7 @@ varnish v2 -arg "-sdebug=debug,dopen=5s -pstartup_timeout=2s -pcli_timeout=3s" \ varnish v2 -cliexpect \ "launch within cli_timeout=3.00s .tip: set startup_" \ "start" +# "time for the big quit" varnish v2 -cliok "panic.clear" varnish v2 -wait @@ -42,5 +43,7 @@ process p2 { varnishd \ -n ${tmpdir}/p2 -a :0 -b none } -expect-exit 0x2 -run +shell {grep -q "time for the big quit" ${p2_err}} + # see explanation of previous shell grep shell {grep -q "launch within cli_timeout=3.00s (tip: set startup_" ${p2_err}} From nils.goroll at uplex.de Mon Jul 3 19:43:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Jul 2023 19:43:05 +0000 (UTC) Subject: [master] 57bf3c576 r3940: tolerate v1 panic registration Message-ID: <20230703194305.AE78511F9B5@lists.varnish-cache.org> commit 57bf3c5766a326d4dc97d479974c10cf4377d49f Author: Nils Goroll Date: Mon Jul 3 21:42:25 2023 +0200 r3940: tolerate v1 panic registration Some systems see it, others not diff --git a/bin/varnishtest/tests/r03940.vtc b/bin/varnishtest/tests/r03940.vtc index b017adc5c..4da082c2d 100644 --- a/bin/varnishtest/tests/r03940.vtc +++ b/bin/varnishtest/tests/r03940.vtc @@ -12,8 +12,11 @@ varnish v1 -arg "-sdebug=debug,dinit=5s -pstartup_timeout=3s -pcli_timeout=2s" \ varnish v1 -cliexpect \ "Child failed on launch within startup_timeout=3.00s" \ "start" +# v1 registers a panic on some systems, but not others +shell {varnishadm -n ${v1_name} panic.clear || true } varnish v1 -wait + process p1 { varnishd \ -sdebug=debug,dinit=5s \ -pstartup_timeout=3s -pcli_timeout=2s \ From nils.goroll at uplex.de Tue Jul 4 06:29:11 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 4 Jul 2023 06:29:11 +0000 (UTC) Subject: [master] 48681cc87 r3940: seeing a different panic again, do not insist on big quit for now Message-ID: <20230704062911.0C2EF9687B@lists.varnish-cache.org> commit 48681cc872c17d339bb6ddb47304db0685e844ba Author: Nils Goroll Date: Tue Jul 4 08:25:07 2023 +0200 r3940: seeing a different panic again, do not insist on big quit for now FreeBSD/arm (not 64) vtester **** p2 stderr|Error: Child failed on launch within cli_timeout=3.00s (tip: set startup_timeout) **** p2 stderr|Error: Child (29805) said Child starts **** p2 stderr|Error: Child (29805) said -sdebug init delay 0.000000s **** p2 stderr|Error: Child (29805) said -sdebug open delay in init 5.000000s **** p2 stderr|Error: Child (29805) died signal=6 **** p2 stderr|Error: Child (29805) said Wrong turn in cli_quit(), ../../../../bin/varnishd/cache/cache_main.c line 371: pthread_kill(cli_thread, sig) failed **** p2 stderr|Error: Child (29805) said errno = 22 (Invalid argument) **** p2 stderr|Error: Child (29805) said Wrong turn in child_signal_handler(), ../../../../bin/varnishd/cache/cache_main.c line 327: Signal 6 (Abort trap) received at 0x0 si_code 65543 **** p2 stderr|Error: Child (29805) said errno = 22 (Invalid argument) diff --git a/bin/varnishtest/tests/r03940.vtc b/bin/varnishtest/tests/r03940.vtc index 4da082c2d..ad826247d 100644 --- a/bin/varnishtest/tests/r03940.vtc +++ b/bin/varnishtest/tests/r03940.vtc @@ -46,7 +46,8 @@ process p2 { varnishd \ -n ${tmpdir}/p2 -a :0 -b none } -expect-exit 0x2 -run -shell {grep -q "time for the big quit" ${p2_err}} +# XXX not reliably the only failure mode +#shell {grep -q "time for the big quit" ${p2_err}} # see explanation of previous shell grep shell {grep -q "launch within cli_timeout=3.00s (tip: set startup_" ${p2_err}} From dridi.boukelmoune at gmail.com Thu Jul 6 15:17:13 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 6 Jul 2023 15:17:13 +0000 (UTC) Subject: [master] 75c7cb291 Change data array definition to use VSL_WORDS Message-ID: <20230706151713.61FE9621DD@lists.varnish-cache.org> commit 75c7cb291ab32b34a26ba138c76d2be45e028cb6 Author: Darryl Rodden Date: Tue Mar 7 10:16:41 2023 -0700 Change data array definition to use VSL_WORDS diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index a28bc70b1..14d3dc20d 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -93,7 +93,7 @@ struct synth { VTAILQ_ENTRY(synth) list; size_t offset; - uint32_t data[VSL_OVERHEAD + 64 / sizeof (uint32_t)]; + uint32_t data[VSL_OVERHEAD + VSL_WORDS(64)]; }; VTAILQ_HEAD(synthhead, synth); From dridi.boukelmoune at gmail.com Thu Jul 6 15:17:13 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 6 Jul 2023 15:17:13 +0000 (UTC) Subject: [master] b4968da50 Use VSL_DATA and VSL_BYTES macros Message-ID: <20230706151713.7061C621DF@lists.varnish-cache.org> commit b4968da505d28c4b8967702c84941301363ee44e Author: Darryl Rodden Date: Tue Mar 7 10:27:13 2023 -0700 Use VSL_DATA and VSL_BYTES macros diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 14d3dc20d..25e1e81b0 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -1038,8 +1038,8 @@ vtx_synth_rec(struct vtx *vtx, unsigned tag, const char *fmt, ...) ALLOC_OBJ(synth, SYNTH_MAGIC); AN(synth); - buf = (char *)&synth->data[VSL_OVERHEAD]; - buflen = sizeof (synth->data) - VSL_OVERHEAD * sizeof (uint32_t); + buf = VSL_DATA(synth->data); + buflen = sizeof(synth->data) - VSL_BYTES(VSL_OVERHEAD); va_start(ap, fmt); l = vsnprintf(buf, buflen, fmt, ap); assert(l >= 0); From nils.goroll at uplex.de Fri Jul 7 10:00:17 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 7 Jul 2023 10:00:17 +0000 (UTC) Subject: [master] 471636824 No newlines in VSC fields Message-ID: <20230707100017.CE3F55FDC@lists.varnish-cache.org> commit 471636824ccfbd217a0abf35250738396b3fdcaa Author: Nils Goroll Date: Fri Jul 7 11:58:41 2023 +0200 No newlines in VSC fields Ref #3948 diff --git a/bin/varnishd/common/common_vsmw.c b/bin/varnishd/common/common_vsmw.c index 758ac82fa..275d8f05c 100644 --- a/bin/varnishd/common/common_vsmw.c +++ b/bin/varnishd/common/common_vsmw.c @@ -151,6 +151,11 @@ vsmw_idx_head(const struct vsmw *vsmw, int fd) assert(write(fd, buf, strlen(buf)) == strlen(buf)); } +#define ASSERT_SEG_STR(x) do { \ + AN(x); \ + AZ(strchr(x, '\n')); \ + } while (0); + static void vsmw_fmt_index(const struct vsmw *vsmw, const struct vsmwseg *seg, char act) { @@ -159,6 +164,9 @@ vsmw_fmt_index(const struct vsmw *vsmw, const struct vsmwseg *seg, char act) CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC); CHECK_OBJ_NOTNULL(seg, VSMWSEG_MAGIC); AN(seg->cluster); + ASSERT_SEG_STR(seg->category); + ASSERT_SEG_STR(seg->id); + VSB_printf(vsmw->vsb, "%c %s %zu %zu %s %s\n", act, seg->cluster->fn, From nils.goroll at uplex.de Sun Jul 9 11:14:11 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 9 Jul 2023 11:14:11 +0000 (UTC) Subject: [master] 046724d6c Minor refactor of sml_objfree(): Add local variable for stevedore Message-ID: <20230709111411.0D8879B937@lists.varnish-cache.org> commit 046724d6cc2660299e8d98c226b82b4a800c404b Author: Nils Goroll Date: Sun Jul 9 13:12:08 2023 +0200 Minor refactor of sml_objfree(): Add local variable for stevedore diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 5735eed7e..71f941e34 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -252,21 +252,25 @@ sml_slim(struct worker *wrk, struct objcore *oc) static void v_matchproto_(objfree_f) sml_objfree(struct worker *wrk, struct objcore *oc) { + const struct stevedore *stv; struct storage *st; struct object *o; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - sml_slim(wrk, oc); + stv = oc->stobj->stevedore; + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); + + sml_slim(wrk, oc); st = o->objstore; CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); FINI_OBJ(o); - if (oc->boc == NULL && oc->stobj->stevedore->lru != NULL) + if (oc->boc == NULL && stv->lru != NULL) LRU_Remove(oc); - sml_stv_free(oc->stobj->stevedore, st); + sml_stv_free(stv, st); memset(oc->stobj, 0, sizeof oc->stobj); From nils.goroll at uplex.de Sun Jul 9 13:02:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 9 Jul 2023 13:02:05 +0000 (UTC) Subject: [master] ad3fa105b Varnishtest: Generalize varnishd_args to varnishd_args_(pre|ap)pend Message-ID: <20230709130205.BA22BA2445@lists.varnish-cache.org> commit ad3fa105b35654f768cdd684b13241d05b3e661f Author: Nils Goroll Date: Sun Jul 9 14:53:57 2023 +0200 Varnishtest: Generalize varnishd_args to varnishd_args_(pre|ap)pend diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 6b2191450..59941b3db 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -406,6 +406,10 @@ varnish_launch(struct varnish *v) VSB_cat(vsb, "cd ${pwd} &&"); VSB_printf(vsb, " exec varnishd %s -d -n %s -i %s", v->jail, v->workdir, v->name); + if (macro_isdef(NULL, "varnishd_args_prepend")) { + VSB_putc(vsb, ' '); + macro_cat(v->vl, vsb, "varnishd_args_prepend", NULL); + } VSB_cat(vsb, VSB_data(params_vsb)); if (leave_temp) { VSB_cat(vsb, " -p debug=+vcl_keep"); @@ -430,9 +434,9 @@ varnish_launch(struct varnish *v) if (vmod_path != NULL) VSB_printf(vsb, " -p vmod_path=%s", vmod_path); VSB_printf(vsb, " %s", VSB_data(v->args)); - if (macro_isdef(NULL, "varnishd_args")) { + if (macro_isdef(NULL, "varnishd_args_append")) { VSB_putc(vsb, ' '); - macro_cat(v->vl, vsb, "varnishd_args", NULL); + macro_cat(v->vl, vsb, "varnishd_args_append", NULL); } AZ(VSB_finish(vsb)); vtc_log(v->vl, 3, "CMD: %s", VSB_data(vsb)); @@ -1072,11 +1076,12 @@ vsl_catchup(struct varnish *v) * \-arg STRING * Pass an argument to varnishd, for example "-h simple_list". * - * If the ${varnishd_args} macro is defined, it is expanded and - * appended to the varnishd command line, before the command line - * itself is expanded. This enables tweaks to the varnishd command - * line without editing test cases. This macro can be defined using - * the ``-D`` option for varnishtest. + * If the ${varnishd_args_prepend} or ${varnishd_args_append} macros are + * defined, they are expanded and inserted before / appended to the + * varnishd command line as constructed by varnishtest, before the + * command line itself is expanded. This enables tweaks to the varnishd + * command line without editing test cases. This macros can be defined + * using the ``-D`` option for varnishtest. * * \-vcl STRING * Specify the VCL to load on this Varnish instance. You'll probably From dridi.boukelmoune at gmail.com Mon Jul 10 08:00:10 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Jul 2023 08:00:10 +0000 (UTC) Subject: [master] 3dccf13ee cocci: Capture TAKE_OBJ_NOTNULL() from casts Message-ID: <20230710080010.683B19CFF8@lists.varnish-cache.org> commit 3dccf13ee0b98b7fce0c590f95f9f088d9157f37 Author: Dridi Boukelmoune Date: Mon Jul 10 09:55:31 2023 +0200 cocci: Capture TAKE_OBJ_NOTNULL() from casts Inspired by #3954. diff --git a/tools/coccinelle/take_obj_notnull.cocci b/tools/coccinelle/take_obj_notnull.cocci index abd31fc38..f99009c06 100644 --- a/tools/coccinelle/take_obj_notnull.cocci +++ b/tools/coccinelle/take_obj_notnull.cocci @@ -69,3 +69,19 @@ expression obj, objp, magic; ... - CHECK_OBJ_NOTNULL(obj, magic); + TAKE_OBJ_NOTNULL(obj, objp, magic); + +@@ +expression obj, priv, magic; +@@ + +- CAST_OBJ_NOTNULL(obj, *priv, magic); +- *priv = NULL; ++ TAKE_OBJ_NOTNULL(obj, priv, magic); + +@@ +expression obj, priv, magic; +@@ + +- CAST_OBJ_NOTNULL(obj, priv, magic); +- priv = NULL; ++ TAKE_OBJ_NOTNULL(obj, &priv, magic); From dridi.boukelmoune at gmail.com Mon Jul 10 08:00:10 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Jul 2023 08:00:10 +0000 (UTC) Subject: [master] 52320df6d cocci: Apply take_obj_notnull.cocci for casts Message-ID: <20230710080010.736B49CFFA@lists.varnish-cache.org> commit 52320df6d3f5a9bc8ab1b0fdbc75ff700bdfcb0a Author: Dridi Boukelmoune Date: Mon Jul 10 09:57:26 2023 +0200 cocci: Apply take_obj_notnull.cocci for casts Avoiding conflicts with #3954. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index c3b7cbb7f..02af9fd27 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -796,8 +796,7 @@ ved_gzgz_fini(struct vdp_ctx *vdc, void **priv) struct ved_foo *foo; (void)vdc; - CAST_OBJ_NOTNULL(foo, *priv, VED_FOO_MAGIC); - *priv = NULL; + TAKE_OBJ_NOTNULL(foo, priv, VED_FOO_MAGIC); /* XXX * this works due to the esi layering, a VDP pushing bytes from _fini diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index d97985734..c1434dc62 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -693,8 +693,7 @@ vfp_gzip_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (vfe->priv1 != NULL) { - CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); - vfe->priv1 = NULL; + TAKE_OBJ_NOTNULL(vg, &vfe->priv1, VGZ_MAGIC); (void)VGZ_Destroy(&vg); } } diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 2424947e3..dbf10fec1 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -242,8 +242,7 @@ hcb_insert(const struct worker *wrk, struct hcb_root *root, /* Insert */ - CAST_OBJ_NOTNULL(y2, wrk->wpriv->nhashpriv, HCB_Y_MAGIC); - wrk->wpriv->nhashpriv = NULL; + TAKE_OBJ_NOTNULL(y2, &wrk->wpriv->nhashpriv, HCB_Y_MAGIC); (void)hcb_crit_bit(digest, oh2, y2); s2 = (digest[y2->ptr] & y2->bitmask) != 0; assert(s2 < 2); From dridi.boukelmoune at gmail.com Mon Jul 10 13:05:07 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Jul 2023 13:05:07 +0000 (UTC) Subject: [master] f337b2c98 vtc: Move disabled tests in the tests/ directory Message-ID: <20230710130507.CBDC9AAAB3@lists.varnish-cache.org> commit f337b2c98091f90decdaca96be2a180f3aa47d2a Author: Dridi Boukelmoune Date: Mon Jul 10 08:07:05 2023 +0200 vtc: Move disabled tests in the tests/ directory This should make them stand out more, and help revisit them more frequently. diff --git a/bin/varnishtest/tests.disabled/README b/bin/varnishtest/tests.disabled/README deleted file mode 100644 index 7b44514f2..000000000 --- a/bin/varnishtest/tests.disabled/README +++ /dev/null @@ -1,5 +0,0 @@ -Tests in this directory are not executed automatically on 'make check'. - -The main reason for a test to live here is when the underlying problem -isn't fixed yet, but a test case exists. This avoids breaking the rest of -the 'make check' tests while a fix is being produced. diff --git a/bin/varnishtest/tests/README b/bin/varnishtest/tests/README index a39d117d1..067bf1a9c 100644 --- a/bin/varnishtest/tests/README +++ b/bin/varnishtest/tests/README @@ -37,3 +37,9 @@ Naming scheme id ~ ^x --> VEXT tests Coverage for individual VMODs is in "${top_srcdir}vmod/tests". + +Tests suffixed with .disabled are not executed automatically on 'make check'. + +The main reason for a test to live here is when the underlying problem +isn't fixed yet, but a test case exists. This avoids breaking the rest of +the 'make check' tests while a fix is being produced. diff --git a/bin/varnishtest/tests.disabled/e00029.vtc b/bin/varnishtest/tests/e00029.vtc.disabled similarity index 100% rename from bin/varnishtest/tests.disabled/e00029.vtc rename to bin/varnishtest/tests/e00029.vtc.disabled diff --git a/bin/varnishtest/tests.disabled/r01252.vtc b/bin/varnishtest/tests/r01252.vtc.disabled similarity index 100% rename from bin/varnishtest/tests.disabled/r01252.vtc rename to bin/varnishtest/tests/r01252.vtc.disabled diff --git a/bin/varnishtest/tests.disabled/r02295.vtc b/bin/varnishtest/tests/r02295.vtc.disabled similarity index 100% rename from bin/varnishtest/tests.disabled/r02295.vtc rename to bin/varnishtest/tests/r02295.vtc.disabled From dridi.boukelmoune at gmail.com Mon Jul 10 13:05:07 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Jul 2023 13:05:07 +0000 (UTC) Subject: [master] 3f67c2d37 vtc: Disable c124 Message-ID: <20230710130507.E5B95AAAB8@lists.varnish-cache.org> commit 3f67c2d37739132952175047aae6dbe7f0144486 Author: Dridi Boukelmoune Date: Mon Jul 10 08:11:53 2023 +0200 vtc: Disable c124 diff --git a/bin/varnishtest/tests/c00124.vtc b/bin/varnishtest/tests/c00124.vtc.disabled similarity index 89% rename from bin/varnishtest/tests/c00124.vtc rename to bin/varnishtest/tests/c00124.vtc.disabled index 2da09f139..898d678e3 100644 --- a/bin/varnishtest/tests/c00124.vtc +++ b/bin/varnishtest/tests/c00124.vtc.disabled @@ -1,5 +1,9 @@ varnishtest "rushed task queued" +# this does not work reliably because the acceptor task may +# be queued during the child startup if not all threads are +# created + # thread reserve mitigation barrier barrier b0 sock 2 @@ -61,12 +65,14 @@ varnish v1 -expect threads == 5 client c1 { txreq -hdr "Cookie: foo" -hdr "server: s1" rxresp + expect resp.status == 200 } -start # 2 threads client c2 { txreq -hdr "server: s2" rxresp + expect resp.status == 200 } -start # ensure c1 and c2 fetch tasks are started @@ -84,11 +90,11 @@ varnish v1 -expect sess_dropped == 0 varnish v1 -expect sess_queued == 0 # At this point, we are thread-starved and c3 below will steal the -# acceptor thread. It will be queued before the acceptor task queues -# itself with a lower priority. +# acceptor thread that will queue itself. client c3 { txreq rxresp + expect resp.status == 200 } -start logexpect l1 -wait From nils.goroll at uplex.de Tue Jul 11 19:29:08 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 19:29:08 +0000 (UTC) Subject: [master] b76e25bd3 Chère coccinelle, ma vie devient si cruelle Message-ID: <20230711192908.40ACD9495C@lists.varnish-cache.org> commit b76e25bd38a29ea2dee26cf5f4595c7a84f3cc39 Author: Nils Goroll Date: Tue Jul 11 20:40:54 2023 +0200 Ch?re coccinelle, ma vie devient si cruelle diff --git a/tools/coccinelle/README.rst b/tools/coccinelle/README.rst index 8b24b0583..a611aed76 100644 --- a/tools/coccinelle/README.rst +++ b/tools/coccinelle/README.rst @@ -1,8 +1,14 @@ .. Copyright (c) 2019-2022 Varnish Software AS + Copyright 2023 UPLEX - Nils Goroll Systemoptimierung SPDX-License-Identifier: BSD-2-Clause See LICENSE file for full text of license +THE EASY PART +============= + +.. _coccinelle: http://coccinelle.lip6.fr/ + This directory contains `coccinelle`_ semantic patches to facilitate code maintenance. @@ -30,4 +36,64 @@ should not need again, but want to retain for reference. Do not commit any ``libvgz`` changes, as this code is manually kept in sync with upstream. -.. _coccinelle: http://coccinelle.lip6.fr/ +THE HARD PART +============= + +*or: a word of warning.* + +Coccinelle does not like our way of using macros for code generation, +but it will silently ignore anything it does not understand, so it +will not cause any harm. + +Except when it does. Ruin your day. + +Because you wonder why code which clearly should match on a semantic +patch does not. + +Take this example, which motivated this section to be written:: + + @@ + type T; + T e1, e2; + @@ + + - vmin_t(T, e1, e2) + + vmin(e1, e2) + +simple as can be: For a type ``T``, replace ``vmin_t(T, ..., ...)`` for +expressions which are also of type ``T``. + +Yet, why does it not change this code ... + +:: + + static int + vcl_acl_cmp(const struct acl_e *ae1, const struct acl_e *ae2) + { + // ... + m = vmin_t(unsigned, ae1->mask, ae2->mask); + +when it does in fact change similar places. + +Reason: It could not parse the ``struct acl_e`` declaration, so it +could not determine that the ``mask`` member is in fact of type +``unsigned``. + +Check for parse errors +---------------------- + +In such cases, *do* check for parse errors in the affected file using +``spatch --parse-c``. Here's a one-liner to check the whole tree:: + + for file in $(find . -name \*.c) ; do + if spatch --macro-file tools/coccinelle/vdef.h \ + -I include/ -I bin/varnishd/ --parse-c $file 2>&1 | + grep -C 5 -E '^BAD' ; then + echo ; echo $file + fi + done + +There are many cases for which no obvious workaround exists yet, but +some have been added to ``tools/coccinelle/vdef.h``. + +Good lug with the ladybug. diff --git a/tools/coccinelle/vdef.h b/tools/coccinelle/vdef.h index ba0248a30..3562dce21 100644 --- a/tools/coccinelle/vdef.h +++ b/tools/coccinelle/vdef.h @@ -1,3 +1,8 @@ +/* + * IF you wonder about the stupid contents of this file, + * DO read tools/coccinelle/README.rst + */ + /* vdef.h */ #define v_printflike_(f,a) #define v_deprecated_ @@ -11,3 +16,14 @@ /* vcc_if.h */ #define VPFX(a) vmod_##a + +/* vqueue.h */ +#define VTAILQ_ENTRY(x) unsigned +#define VSTAILQ_ENTRY(x) unsigned +#define VTAILQ_HEAD(x, y) unsigned +#define VSTAILQ_HEAD(x, y) unsigned +#define VRBT_ENTRY(x) unsigned +#define VRBT_HEAD(x, y) unsigned + +/* lib/libvcc/vcc_vmod.c */ +#define STANZA_TBL From nils.goroll at uplex.de Tue Jul 11 19:29:08 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 19:29:08 +0000 (UTC) Subject: [master] 8b67e5bb8 Coccinelle: patch v{min,max}_t -> v{min,max} Message-ID: <20230711192908.63FC19495E@lists.varnish-cache.org> commit 8b67e5bb86888d28409ea313e32937aa3522c5bb Author: Nils Goroll Date: Tue Jul 11 21:27:37 2023 +0200 Coccinelle: patch v{min,max}_t -> v{min,max} diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index e1ae6e286..971c65ae6 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -304,7 +304,7 @@ VSLv(enum VSL_tag_e tag, vxid_t vxid, const char *fmt, va_list ap) vslr(tag, vxid, fmt, strlen(fmt) + 1); } else { n = vsnprintf(buf, mlen, fmt, ap); - n = vmin_t(unsigned, n, mlen - 1); + n = vmin(n, mlen - 1); buf[n++] = '\0'; /* NUL-terminated */ vslr(tag, vxid, buf, n); } diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index be3d6fd67..f989d001c 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -272,7 +272,7 @@ h2_do_window(struct worker *wrk, struct h2_req *r2, (void)h2_cond_wait(h2->winupd_cond, h2, r2); if (h2_errcheck(r2, h2) == 0) { - w = vmin_t(int64_t, h2_win_limit(r2, h2), wanted); + w = vmin(h2_win_limit(r2, h2), wanted); h2_win_charge(r2, h2, w); assert (w > 0); } diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index 4d8abe18a..427392873 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -157,7 +157,7 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) AZ(VFIL_fsinfo(fd, &bs, &fssize, NULL)); /* Increase granularity if it is lower than the filesystem block size */ - *granularity = vmax_t(unsigned, *granularity, bs); + *granularity = vmax(*granularity, bs); if ((size == NULL || *size == '\0') && st.st_size != 0) { /* diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 818693670..85baac4ca 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -105,7 +105,7 @@ vcl_acl_cmp(const struct acl_e *ae1, const struct acl_e *ae2) p1 = ae1->data; p2 = ae2->data; - m = vmin_t(unsigned, ae1->mask, ae2->mask); + m = vmin(ae1->mask, ae2->mask); for (; m >= 8; m -= 8) { CMP(*p1, *p2); p1++; diff --git a/tools/coccinelle/vminmax.cocci b/tools/coccinelle/vminmax.cocci new file mode 100644 index 000000000..b3ebe292c --- /dev/null +++ b/tools/coccinelle/vminmax.cocci @@ -0,0 +1,16 @@ +/* + * This patch refactors v{min,max}_t to v{min,max} where types agree + * + * Note: Has false positives on pointer types, tolerated for clarity + */ +using "varnish.iso" + +@@ type T; T e1, e2; @@ + +- vmin_t(T, e1, e2) ++ vmin(e1, e2) + +@@ type T; T e1, e2; @@ + +- vmax_t(T, e1, e2) ++ vmax(e1, e2) diff --git a/vmod/vmod_directors_shard_cfg.c b/vmod/vmod_directors_shard_cfg.c index aec4a0901..f03a96361 100644 --- a/vmod/vmod_directors_shard_cfg.c +++ b/vmod/vmod_directors_shard_cfg.c @@ -275,7 +275,7 @@ shardcfg_hashcircle(struct sharddir *shardd) rmax = (UINT32_MAX - 1) / shardd->n_backend; for (b = backends; b < backends + shardd->n_backend; b++) { CHECK_OBJ_NOTNULL(b->backend, DIRECTOR_MAGIC); - n_points += vmin_t(uint32_t, b->replicas, rmax); + n_points += vmin(b->replicas, rmax); } assert(n_points < UINT32_MAX); @@ -291,7 +291,7 @@ shardcfg_hashcircle(struct sharddir *shardd) AN(ident); assert(ident[0] != '\0'); - r = vmin_t(uint32_t, b->replicas, rmax); + r = vmin(b->replicas, rmax); for (j = 0; j < r; j++) { assert(snprintf(s, len, "%d", j) < len); From nils.goroll at uplex.de Tue Jul 11 19:31:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 19:31:05 +0000 (UTC) Subject: [master] bbd44818d Flexelinting Message-ID: <20230711193105.33A3E94D5B@lists.varnish-cache.org> commit bbd44818da4eb10e46e1855a0e19694f6f817168 Author: Nils Goroll Date: Tue Jul 11 21:30:30 2023 +0200 Flexelinting diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 6b7c2b0e7..b4fd329bb 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -57,7 +57,6 @@ #include "vtim.h" #include "common/heritage.h" -#include "common/vsmw.h" static pid_t child_pid = -1; @@ -450,7 +449,7 @@ mgt_launch_child(struct cli *cli) bstart ? "startup" : "cli", dstart, bstart ? "" : " (tip: set startup_timeout)"); child_pid = pid; - kill_child(); + (void)kill_child(); mgt_reap_child(); child_state = CH_STOPPED; return; From nils.goroll at uplex.de Tue Jul 11 19:41:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 19:41:05 +0000 (UTC) Subject: [master] 10d6c120f Reapply free_obj.cocci now that coccinelle can parse more Message-ID: <20230711194105.41EBC954B8@lists.varnish-cache.org> commit 10d6c120f3cc703297e0a1b4ea7687a236bc9957 Author: Nils Goroll Date: Tue Jul 11 21:34:30 2023 +0200 Reapply free_obj.cocci now that coccinelle can parse more diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index ba3b54c08..e576bca04 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -636,7 +636,7 @@ via_endpoint(const struct vrt_endpoint *vep, const struct suckaddr *sa, ret = VRT_Endpoint_Clone(nvep); CHECK_OBJ_NOTNULL(ret, VRT_ENDPOINT_MAGIC); VSB_destroy(&preamble); - free(nvep); + FREE_OBJ(nvep); return (ret); } From nils.goroll at uplex.de Tue Jul 11 19:41:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 19:41:05 +0000 (UTC) Subject: [master] b6b979072 Flexelint vmin/vmax Message-ID: <20230711194105.5496C954BB@lists.varnish-cache.org> commit b6b97907206561dd95cc35aebae4913406200277 Author: Nils Goroll Date: Tue Jul 11 21:39:18 2023 +0200 Flexelint vmin/vmax someone(tm) should have checked the history and found 9fd79a7cb69aad1597101aca6608d8bf8c03952d diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index f989d001c..be3d6fd67 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -272,7 +272,7 @@ h2_do_window(struct worker *wrk, struct h2_req *r2, (void)h2_cond_wait(h2->winupd_cond, h2, r2); if (h2_errcheck(r2, h2) == 0) { - w = vmin(h2_win_limit(r2, h2), wanted); + w = vmin_t(int64_t, h2_win_limit(r2, h2), wanted); h2_win_charge(r2, h2, w); assert (w > 0); } diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index 427392873..4d8abe18a 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -157,7 +157,7 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) AZ(VFIL_fsinfo(fd, &bs, &fssize, NULL)); /* Increase granularity if it is lower than the filesystem block size */ - *granularity = vmax(*granularity, bs); + *granularity = vmax_t(unsigned, *granularity, bs); if ((size == NULL || *size == '\0') && st.st_size != 0) { /* From nils.goroll at uplex.de Tue Jul 11 19:46:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 19:46:05 +0000 (UTC) Subject: [master] cef6d49bd Polish min usage for SunCC Message-ID: <20230711194605.0EC7095A59@lists.varnish-cache.org> commit cef6d49bdee501dd452c60bd63ad2be870ad1453 Author: Nils Goroll Date: Mon Nov 8 18:01:38 2021 +0100 Polish min usage for SunCC Fixes: left operand must be modifiable lvalue: op "=" Same as: 64f7181b1d337309e2bcae8a10be5f626f009e36 This leaves exactly one commit after the coccinelle efforts. What a waste of time. :| diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 85baac4ca..818693670 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -105,7 +105,7 @@ vcl_acl_cmp(const struct acl_e *ae1, const struct acl_e *ae2) p1 = ae1->data; p2 = ae2->data; - m = vmin(ae1->mask, ae2->mask); + m = vmin_t(unsigned, ae1->mask, ae2->mask); for (; m >= 8; m -= 8) { CMP(*p1, *p2); p1++; diff --git a/vmod/vmod_directors_shard_cfg.c b/vmod/vmod_directors_shard_cfg.c index f03a96361..aec4a0901 100644 --- a/vmod/vmod_directors_shard_cfg.c +++ b/vmod/vmod_directors_shard_cfg.c @@ -275,7 +275,7 @@ shardcfg_hashcircle(struct sharddir *shardd) rmax = (UINT32_MAX - 1) / shardd->n_backend; for (b = backends; b < backends + shardd->n_backend; b++) { CHECK_OBJ_NOTNULL(b->backend, DIRECTOR_MAGIC); - n_points += vmin(b->replicas, rmax); + n_points += vmin_t(uint32_t, b->replicas, rmax); } assert(n_points < UINT32_MAX); @@ -291,7 +291,7 @@ shardcfg_hashcircle(struct sharddir *shardd) AN(ident); assert(ident[0] != '\0'); - r = vmin(b->replicas, rmax); + r = vmin_t(uint32_t, b->replicas, rmax); for (j = 0; j < r; j++) { assert(snprintf(s, len, "%d", j) < len); From nils.goroll at uplex.de Tue Jul 11 19:49:04 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 19:49:04 +0000 (UTC) Subject: [master] 4c9ab3c1a Reapply printf_nofmt.cocci now that coccinelle can parse more Message-ID: <20230711194905.074D795DC8@lists.varnish-cache.org> commit 4c9ab3c1ace14ab7ce68e80f731dc2d9c316b15f Author: Nils Goroll Date: Tue Jul 11 21:45:39 2023 +0200 Reapply printf_nofmt.cocci now that coccinelle can parse more diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index 81f0da98a..c199e2d36 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -591,7 +591,7 @@ vcc_ParseHostDef(struct vcc *tl, struct symbol *sym, } if (via != NULL && t_path != NULL) { - VSB_printf(tl->sb, "Cannot set both .via and .path.\n"); + VSB_cat(tl->sb, "Cannot set both .via and .path.\n"); vcc_ErrWhere(tl, t_be); return; } From nils.goroll at uplex.de Tue Jul 11 19:49:05 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 19:49:05 +0000 (UTC) Subject: [master] d353c4153 Reapply pthread_errno.cocci now that coccinelle can parse more Message-ID: <20230711194905.1CE1795DCC@lists.varnish-cache.org> commit d353c4153883e60c172a6e9bc9fa4e3f787d621d Author: Nils Goroll Date: Tue Jul 11 21:46:01 2023 +0200 Reapply pthread_errno.cocci now that coccinelle can parse more diff --git a/vmod/vmod_blob.c b/vmod/vmod_blob.c index 4afb739df..c9f675eb5 100644 --- a/vmod/vmod_blob.c +++ b/vmod/vmod_blob.c @@ -296,7 +296,7 @@ vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs, } } } - AZ(pthread_mutex_unlock(&b->lock)); + PTOK(pthread_mutex_unlock(&b->lock)); } return (b->encoding[enc][kase]); } From nils.goroll at uplex.de Tue Jul 11 20:21:06 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 20:21:06 +0000 (UTC) Subject: [master] d99f62a9c Use vmin_t in vcl_acl_disjoint() Message-ID: <20230711202107.1E9CD972C1@lists.varnish-cache.org> commit d99f62a9c5d4c6de492abae63510555d51a53324 Author: Nils Goroll Date: Tue Jul 11 22:12:43 2023 +0200 Use vmin_t in vcl_acl_disjoint() diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 818693670..dffd9013c 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -133,9 +133,7 @@ vcl_acl_disjoint(const struct acl_e *ae1, const struct acl_e *ae2) p1 = ae1->data; p2 = ae2->data; - m = ae1->mask; - if (ae2->mask < m) - m = ae2->mask; + m = vmin_t(unsigned, ae1->mask, ae2->mask); for (; m >= 8; m -= 8) { CMP(*p1, *p2); p1++; From nils.goroll at uplex.de Tue Jul 11 22:49:08 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 11 Jul 2023 22:49:08 +0000 (UTC) Subject: [master] 81a0a3039 Try to stabilize r03159 Message-ID: <20230711224908.755E1A2563@lists.varnish-cache.org> commit 81a0a303958d9a8e69f85f8b0e64fb172b7a4680 Author: Nils Goroll Date: Wed Jul 12 00:48:26 2023 +0200 Try to stabilize r03159 diff --git a/bin/varnishtest/tests/r03159.vtc b/bin/varnishtest/tests/r03159.vtc index d165d4c2d..a0c455f9a 100644 --- a/bin/varnishtest/tests/r03159.vtc +++ b/bin/varnishtest/tests/r03159.vtc @@ -16,6 +16,7 @@ process p1 -log { shell { # wait for startup vcl.load to complete + varnishadm -n ${tmpdir}/t ping || varnishadm -n ${tmpdir}/t ping } From nils.goroll at uplex.de Wed Jul 12 13:40:16 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 12 Jul 2023 13:40:16 +0000 (UTC) Subject: [master] 45492fd3b ESI: Use response status modulo 1000 Message-ID: <20230712134016.E49849C0B2@lists.varnish-cache.org> commit 45492fd3b0fa3d6692dd6187fd7ec214f82a4cd5 Author: Nils Goroll Date: Wed Jul 12 15:36:51 2023 +0200 ESI: Use response status modulo 1000 Ref: 582ded6a2d6ae1a4467b1eb500f2725b42888016 Fixes #3958 diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 02af9fd27..bb5384c52 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -857,6 +857,7 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) { int i = 0; const char *p; + uint16_t status; struct ecx *ecx; struct ved_foo foo[1]; struct vrt_ctx ctx[1]; @@ -870,9 +871,9 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) if (wantbody == 0) return; - if (!ecx->incl_cont && - req->resp->status != 200 && - req->resp->status != 204) { + status = req->resp->status % 1000; + + if (!ecx->incl_cont && status != 200 && status != 204) { req->top->topreq->vdc->retval = -1; req->top->topreq->doclose = req->doclose; return; diff --git a/bin/varnishtest/tests/e00003.vtc b/bin/varnishtest/tests/e00003.vtc index c03d9f487..dad0d40ab 100644 --- a/bin/varnishtest/tests/e00003.vtc +++ b/bin/varnishtest/tests/e00003.vtc @@ -8,8 +8,7 @@ server s1 { txresp -body { Before include - - After include + After include } rxreq @@ -21,9 +20,17 @@ server s1 { } -start varnish v1 -vcl+backend { + sub vcl_synth { + set resp.body = """ + """; + return (deliver); + } sub vcl_recv { if (req.esi_level > 0) { set req.url = req.url + req.esi_level; + if (req.url ~ "^/synth") { + return (synth(3200)); + } } else { set req.http.esi0 = "foo"; } @@ -64,7 +71,7 @@ logexpect l4 -v v1 -g request { } -start logexpect l5 -v v1 -g request { - expect * 1005 Begin "^req .* rxreq" + expect * 1006 Begin "^req .* rxreq" # Header bytes is 5 larger than in l1 due to two item X-Varnish hdr expect * = ReqAcct "^29 0 29 175 75 250$" expect 0 = End @@ -87,7 +94,7 @@ client c1 { } client c1 -run -varnish v1 -expect esi_req == 2 +varnish v1 -expect esi_req == 4 varnish v1 -expect esi_errors == 0 varnish v1 -expect MAIN.s_resp_bodybytes == 150 @@ -104,7 +111,7 @@ shell { cat >expected.txt <<-EOF 1001 c rxreq - 1005 c rxreq + 1006 c rxreq EOF diff -u expected.txt ncsa.txt } @@ -129,8 +136,10 @@ shell { cat >expected.txt <<-EOF 1001 c rxreq 1003 c esi - 1005 c rxreq - 1006 c esi + 1005 c esi + 1006 c rxreq + 1007 c esi + 1008 c esi EOF diff -u expected.txt ncsa.txt } @@ -145,8 +154,10 @@ shell { 1002 b fetch 1003 c esi 1004 b fetch - 1005 c rxreq - 1006 c esi + 1005 c esi + 1006 c rxreq + 1007 c esi + 1008 c esi EOF diff -u expected.txt ncsa.txt } From dridi.boukelmoune at gmail.com Thu Jul 13 09:50:11 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 13 Jul 2023 09:50:11 +0000 (UTC) Subject: [master] fcfb0308b cocci: Restructure and enrich vdef.h Message-ID: <20230713095011.DC9EDA5201@lists.varnish-cache.org> commit fcfb0308b2c5788902cc17e069d883942741b2cf Author: Dridi Boukelmoune Date: Thu Jul 13 11:39:47 2023 +0200 cocci: Restructure and enrich vdef.h diff --git a/tools/coccinelle/vdef.h b/tools/coccinelle/vdef.h index 3562dce21..b78f0d310 100644 --- a/tools/coccinelle/vdef.h +++ b/tools/coccinelle/vdef.h @@ -3,7 +3,7 @@ * DO read tools/coccinelle/README.rst */ -/* vdef.h */ +/* include/vdef.h */ #define v_printflike_(f,a) #define v_deprecated_ #define v_dont_optimize @@ -11,19 +11,33 @@ #define v_statevariable_(varname) #define v_unused_ -/* vrt.h */ -#define VRT_CTX const struct vrt_ctx *ctx +/* include/vrt.h */ +#define VRT_CTX const struct vrt_ctx *ctx -/* vcc_if.h */ -#define VPFX(a) vmod_##a +/* include/vqueue.h */ +#define VTAILQ_ENTRY(t) unsigned +#define VSTAILQ_ENTRY(t) unsigned -/* vqueue.h */ -#define VTAILQ_ENTRY(x) unsigned -#define VSTAILQ_ENTRY(x) unsigned -#define VTAILQ_HEAD(x, y) unsigned -#define VSTAILQ_HEAD(x, y) unsigned -#define VRBT_ENTRY(x) unsigned -#define VRBT_HEAD(x, y) unsigned +#define VTAILQ_HEAD(n, t) unsigned +#define VSTAILQ_HEAD(n, t) unsigned + +#define VTAILQ_HEAD_INITIALIZER(t) 0 +#define VSTAILQ_HEAD_INITIALIZER(t) 0 + +/* include/vtree.h */ +#define VRBT_ENTRY(x) unsigned +#define VRBT_HEAD(x, y) unsigned +#define VRBT_INITIALIZER(t) 0 /* lib/libvcc/vcc_vmod.c */ #define STANZA_TBL + +/* bin/varnishd/common/heritage.h */ +#define ASSERT_MGT() (void)0 + +/* bin/varnishd/cache/cache_transport.h */ +#define TRANSPORTS + +/* vmod/vcc_*_if.h */ +#define VPFX(a) vmod_##a +#define VARGS(a) arg_vmod_foo_##a From dridi.boukelmoune at gmail.com Thu Jul 13 09:50:11 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 13 Jul 2023 09:50:11 +0000 (UTC) Subject: [master] 35b51e28c cocci: Avoid name collisions in check_obj.cocci Message-ID: <20230713095011.F269CA5206@lists.varnish-cache.org> commit 35b51e28c0066d2dbeea59977a1709e0e7cfc961 Author: Dridi Boukelmoune Date: Thu Jul 13 11:41:13 2023 +0200 cocci: Avoid name collisions in check_obj.cocci I get a new warning with Coccinelle XXX: > magic, previously declared as a metavariable, is used as an identifier I don't remember seeing this warning before, but it looks like @@ blocks may not behave as I thought. I didn't review the other semantic patches. diff --git a/tools/coccinelle/check_obj.cocci b/tools/coccinelle/check_obj.cocci index d82510210..2d121a5ab 100644 --- a/tools/coccinelle/check_obj.cocci +++ b/tools/coccinelle/check_obj.cocci @@ -4,12 +4,12 @@ */ @@ -expression obj, magic; +expression obj, magicval; @@ if (obj != NULL) { -- CHECK_OBJ_NOTNULL(obj, magic); -+ CHECK_OBJ(obj, magic); +- CHECK_OBJ_NOTNULL(obj, magicval); ++ CHECK_OBJ(obj, magicval); ... } From dridi.boukelmoune at gmail.com Thu Jul 13 09:50:12 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 13 Jul 2023 09:50:12 +0000 (UTC) Subject: [master] e15af112d cocci: Masquerade foreach loops as if statements Message-ID: <20230713095012.19DF4A5209@lists.varnish-cache.org> commit e15af112d54008024a9ee09b0c2da91746505d8a Author: Dridi Boukelmoune Date: Thu Jul 13 11:45:52 2023 +0200 cocci: Masquerade foreach loops as if statements Inside the loop the element is in fact, not null. Only one occurrence was caught by check_obj.cocci, which shows that more code is still not understood by Coccinelle. For example, it doesn't seem to enjoy #undef directives inside functions. diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index dbf10fec1..ce7cf6630 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -320,7 +320,7 @@ hcb_cleaner(struct worker *wrk, void *priv) FREE_OBJ(y); } VTAILQ_FOREACH_SAFE(oh, &dead_h, hoh_list, oh2) { - CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + CHECK_OBJ(oh, OBJHEAD_MAGIC); VTAILQ_REMOVE(&dead_h, oh, hoh_list); HSH_DeleteObjHead(wrk, oh); } diff --git a/tools/coccinelle/vdef.h b/tools/coccinelle/vdef.h index b78f0d310..43ca64595 100644 --- a/tools/coccinelle/vdef.h +++ b/tools/coccinelle/vdef.h @@ -24,6 +24,10 @@ #define VTAILQ_HEAD_INITIALIZER(t) 0 #define VSTAILQ_HEAD_INITIALIZER(t) 0 +#define VTAILQ_FOREACH(o, h, l) if (o != NULL) +#define VTAILQ_FOREACH_SAFE(o, h, l, o2) if (o != NULL) +#define VTAILQ_FOREACH_REVERSE(o, h, t, l) if (o != NULL) + /* include/vtree.h */ #define VRBT_ENTRY(x) unsigned #define VRBT_HEAD(x, y) unsigned From nils.goroll at uplex.de Fri Jul 14 17:11:10 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 14 Jul 2023 17:11:10 +0000 (UTC) Subject: [master] 1686b6b6f Flexelinting: include cleanup Message-ID: <20230714171110.A33D36EB6E@lists.varnish-cache.org> commit 1686b6b6f52674716bf2b2017de3b6b51373c4be Author: Nils Goroll Date: Fri Jul 14 18:48:49 2023 +0200 Flexelinting: include cleanup diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index e576bca04..2a9e31edc 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -39,7 +39,6 @@ #include "cache_varnishd.h" #include "cache_director.h" -#include "vsa.h" #include "vtcp.h" #include "vtim.h" #include "vsa.h" diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c index 95327406c..28376f56c 100644 --- a/bin/varnishd/cache/cache_ban_build.c +++ b/bin/varnishd/cache/cache_ban_build.c @@ -40,7 +40,6 @@ #include "vend.h" #include "vtim.h" #include "vnum.h" -#include "vre.h" void BAN_Build_Init(void); void BAN_Build_Fini(void); From nils.goroll at uplex.de Fri Jul 14 18:24:06 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 14 Jul 2023 18:24:06 +0000 (UTC) Subject: [master] de53b7c78 Flexelinting: include cleanup Message-ID: <20230714182406.E671594F89@lists.varnish-cache.org> commit de53b7c7818e8d5f9b594ab6bf40c1f1e824e2b3 Author: Nils Goroll Date: Fri Jul 14 19:40:06 2023 +0200 Flexelinting: include cleanup diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 50bdd403a..c62a8c429 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -33,7 +33,6 @@ #include "cache/cache_varnishd.h" -#include #include #include diff --git a/lib/libvarnish/vfl.c b/lib/libvarnish/vfl.c index 1809dd79e..e28ef374a 100644 --- a/lib/libvarnish/vfl.c +++ b/lib/libvarnish/vfl.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include "vfl.h" diff --git a/lib/libvarnish/vmb.c b/lib/libvarnish/vmb.c index 51a874cd2..326aeb542 100644 --- a/lib/libvarnish/vmb.c +++ b/lib/libvarnish/vmb.c @@ -30,8 +30,6 @@ #include "config.h" -#include "vmb.h" - #ifdef VMB_NEEDS_PTHREAD_WORKAROUND_THIS_IS_BAD_FOR_PERFORMANCE #include @@ -40,6 +38,7 @@ #include "vdef.h" #include "vas.h" +#include "vmb.h" static pthread_mutex_t mb_mtx; static pthread_once_t mb_mtx_once = PTHREAD_ONCE_INIT; diff --git a/lib/libvcc/vcc_storage.c b/lib/libvcc/vcc_storage.c index bb08bc3d3..d088090d4 100644 --- a/lib/libvcc/vcc_storage.c +++ b/lib/libvcc/vcc_storage.c @@ -56,7 +56,6 @@ #include "config.h" -#include #include #include diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 3425c1c86..61d05e156 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -32,7 +32,6 @@ #include "config.h" #include -#include #include #include diff --git a/lib/libvcc/vcc_token.c b/lib/libvcc/vcc_token.c index 580b6cb2f..79af6eb58 100644 --- a/lib/libvcc/vcc_token.c +++ b/lib/libvcc/vcc_token.c @@ -38,7 +38,6 @@ #include "venc.h" #include "vct.h" -#include "vsb.h" /*--------------------------------------------------------------------*/ diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index e998da061..7e7b3b8af 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -42,7 +42,6 @@ #include "vfil.h" #include "vjsn.h" #include "vmod_abi.h" -#include "vsb.h" #include "vcc_vmod.h" diff --git a/lib/libvcc/vcc_vmod_sym.c b/lib/libvcc/vcc_vmod_sym.c index ad2631f5f..e86a1a20e 100644 --- a/lib/libvcc/vcc_vmod_sym.c +++ b/lib/libvcc/vcc_vmod_sym.c @@ -40,7 +40,6 @@ #include "libvcc.h" #include "vjsn.h" -#include "vsb.h" #include "vcc_vmod.h" From nils.goroll at uplex.de Fri Jul 14 18:24:07 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 14 Jul 2023 18:24:07 +0000 (UTC) Subject: [master] c5e3fee66 Flexelinting: symbol not accessed Message-ID: <20230714182407.0774294F8D@lists.varnish-cache.org> commit c5e3fee66f2e524209813763818b76114943be41 Author: Nils Goroll Date: Fri Jul 14 19:40:18 2023 +0200 Flexelinting: symbol not accessed diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 4a21962e9..21d6bc2d3 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -448,13 +448,10 @@ static int telnet_accept(const struct vev *ev, int what) { struct vsb *vsb; - struct sockaddr_storage addr; - socklen_t addrlen; int i; (void)what; - addrlen = sizeof addr; - i = accept(ev->fd, (void *)&addr, &addrlen); + i = accept(ev->fd, NULL, NULL); if (i < 0 && errno == EBADF) return (1); if (i < 0) From nils.goroll at uplex.de Fri Jul 14 18:24:07 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 14 Jul 2023 18:24:07 +0000 (UTC) Subject: [master] 3dd0182fd Silence Flexelint Message-ID: <20230714182407.2EBA194F93@lists.varnish-cache.org> commit 3dd0182fd422b1b58dc343b3b899b11f6fccad0a Author: Nils Goroll Date: Fri Jul 14 19:48:14 2023 +0200 Silence Flexelint my local config on linux is slightly different than phks on freebsd diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index cc0a3c909..d6ea93a47 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -124,6 +124,7 @@ ////////////// +libh mgt_event.h +-esym(522, mgt_ProcTitle) -sem(VRT_AddDirector, custodial(3)) -sem(VCP_New, custodial(3)) diff --git a/lib/libvarnish/vfl.c b/lib/libvarnish/vfl.c index e28ef374a..8c8d1336a 100644 --- a/lib/libvarnish/vfl.c +++ b/lib/libvarnish/vfl.c @@ -35,7 +35,7 @@ #include #include -#include +#include //lint !e537 #include #include diff --git a/lib/libvarnish/vpf.c b/lib/libvarnish/vpf.c index ef6cf27cf..85f381b95 100644 --- a/lib/libvarnish/vpf.c +++ b/lib/libvarnish/vpf.c @@ -34,7 +34,7 @@ #include #include -#include +#include //lint !e537 #include #include #include diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt index 4705d651c..87410ec86 100644 --- a/lib/libvcc/flint.lnt +++ b/lib/libvcc/flint.lnt @@ -13,4 +13,6 @@ -esym(768, token) // FLINTBUG: global struct member 'token' not ref -efile(451, vcc_namespace.h) // No include guard +-efile(537, vcc_namespace.h) // Repeated include -efile(451, vcc_types.h) // No include guard +-efile(537, vcc_types.h) // Repeated include From nils.goroll at uplex.de Fri Jul 14 18:40:06 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 14 Jul 2023 18:40:06 +0000 (UTC) Subject: [master] 60e35b939 Revert vmb.h include move from de53b7c7818e8d5f9b594ab6bf40c1f1e824e2b3 Message-ID: <20230714184006.5DA4995D44@lists.varnish-cache.org> commit 60e35b939f8245376376b00858fe4c841234898a Author: Nils Goroll Date: Fri Jul 14 20:37:38 2023 +0200 Revert vmb.h include move from de53b7c7818e8d5f9b594ab6bf40c1f1e824e2b3 And mark it for flexelint diff --git a/lib/libvarnish/vmb.c b/lib/libvarnish/vmb.c index 326aeb542..c84317714 100644 --- a/lib/libvarnish/vmb.c +++ b/lib/libvarnish/vmb.c @@ -30,6 +30,8 @@ #include "config.h" +#include "vmb.h" //lint !e766 + #ifdef VMB_NEEDS_PTHREAD_WORKAROUND_THIS_IS_BAD_FOR_PERFORMANCE #include @@ -38,7 +40,6 @@ #include "vdef.h" #include "vas.h" -#include "vmb.h" static pthread_mutex_t mb_mtx; static pthread_once_t mb_mtx_once = PTHREAD_ONCE_INIT; From nils.goroll at uplex.de Fri Jul 14 18:43:06 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 14 Jul 2023 18:43:06 +0000 (UTC) Subject: [master] bcf8d3e82 Fix previous lint silence Message-ID: <20230714184306.9D9D5960C8@lists.varnish-cache.org> commit bcf8d3e822669461f7eeb92c9bdab14a76aaa025 Author: Nils Goroll Date: Fri Jul 14 20:41:53 2023 +0200 Fix previous lint silence diff --git a/lib/libvarnish/vmb.c b/lib/libvarnish/vmb.c index c84317714..cb7046db9 100644 --- a/lib/libvarnish/vmb.c +++ b/lib/libvarnish/vmb.c @@ -30,7 +30,8 @@ #include "config.h" -#include "vmb.h" //lint !e766 +//lint -e{766} +#include "vmb.h" #ifdef VMB_NEEDS_PTHREAD_WORKAROUND_THIS_IS_BAD_FOR_PERFORMANCE From nils.goroll at uplex.de Mon Jul 17 13:22:06 2023 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 17 Jul 2023 13:22:06 +0000 (UTC) Subject: [master] 6a3775fa3 Fix a race between VBP_Remove() and vbp_thread() Message-ID: <20230717132206.473FAB1EA6@lists.varnish-cache.org> commit 6a3775fa3f64044b0fbbf8a3e93b791a06ad57fc Author: Nils Goroll Date: Tue Jul 11 23:37:05 2023 +0200 Fix a race between VBP_Remove() and vbp_thread() Suppose the following happens: vbp_task() finishes with vt->running = 0 and a heap insert. The vbp_cond is signaled under the lock, but now instead of vbp_thread() waking up first, VBP_Remove() gets the lock and reaches assert(vt->heap_idx == VBH_NOIDX) before the racing vbp_thread() deleted the heap. This is unlikely to happen with static backends, because for those, the probe is stopped via the vcl temperature before they get removed. Fixes https://github.com/nigoroll/libvmod-dynamic/issues/100 diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 9d7d8b2be..96101fa13 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -710,8 +710,12 @@ VBP_Remove(struct backend *be) be->probe = NULL; vt->backend = NULL; if (vt->running) { + // task scheduled, it calls vbp_delete() vt->running = -1; vt = NULL; + } else if (vt->heap_idx != VBH_NOIDX) { + // task done, not yet rescheduled + VBH_delete(vbp_heap, vt->heap_idx); } Lck_Unlock(&vbp_mtx); if (vt != NULL) { From dridi.boukelmoune at gmail.com Thu Jul 20 07:44:05 2023 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 20 Jul 2023 07:44:05 +0000 (UTC) Subject: [master] 3731e9f97 vcc: Remove stale assertion Message-ID: <20230720074405.94B5410173D@lists.varnish-cache.org> commit 3731e9f97534b632f8b4a3032859df6116e7826c Author: Dridi Boukelmoune Date: Thu Jul 20 09:31:26 2023 +0200 vcc: Remove stale assertion Fixes #3960 diff --git a/bin/varnishtest/tests/r03960.vtc b/bin/varnishtest/tests/r03960.vtc new file mode 100644 index 000000000..2b76da9e7 --- /dev/null +++ b/bin/varnishtest/tests/r03960.vtc @@ -0,0 +1,9 @@ +varnishtest "invalid header name on RHS" + +varnish v1 -errvcl "Expected ID got '0'" { + vcl 4.1; + backend default none; + sub vcl_recv { + if (req.http.0) {} + } +} diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 1d4eb6453..63578df9d 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -370,7 +370,6 @@ vcc_Eval_Var(struct vcc *tl, struct expr **e, struct token *t, { (void)type; - assert(sym->kind == SYM_VAR); vcc_AddUses(tl, t, NULL, sym, XREF_READ); ERRCHK(tl); *e = vcc_mk_expr(sym->type, "%s", sym->rname);