I was messing around with Varnish on my Pi and was a little peeved that it kept crashing right after start up.
Turns out, this issue is well known to the Googles and everyone who’s tried to run it on the Pi, or at least on Raspbian like I am. If you try running Varnish with
-F, you should see something like
child (28856) Started
Pushing vcls failed:
CLI communication error (hdr)
Child (28856) died signal=11
Child (-1) said Child starts
Child cleanup complete
I finally tracked down a page where someone said they avoided the crash bug by compiling with
CFLAGS="-fno-inline" ./configure && make && make install, but I don’t think that worked. I tried with
CFLAGS="-O2 -fno-inline", which should turn on all the
-O2 optimizations but disable inlining since that switch comes after the general optimization switch. When I tried it, it was still crashing on me. Then I realized that if someone used just
CFLAGS, it may very well not use any optimization for the compile, defaulting to
-O0. I surmised that the inline switch wasn’t causing the bug, but instead one of the other optimizations that gets turned on between optimization level 0 and 2.
Various people reported having success with Varnish by compiling with the
--enable-debugging-symbols --enable-diagnostics switches. This explicitly sets
-O0 for compile flags, but I was hoping to do better. Instead I used
CFLAGS="-O1 -pipe" (-pipe just to try to speed up the compile a bit), and after trying it, no crash. Cool!
-O1 is pretty conservative in terms of enabled optimizations, but at least I got some benefit. I suspect there’s just one optimization that causing the failure when using
-O2 but the list of extras it enables would take a while to plow through and test. Here’s the list, since my curiosity got the best of me while I was writing this: GCC optimizations.
P.S.: I installed libjemalloc-dev prior to most of the compiles, since jemalloc is reported to do a better job reducing thread contention and memory fragmentation.