<div dir="ltr"><div>Geoff: I'm not responsible for the Regex.  As you point out, it's ... ah... ill-advised is about as polite as I can be.  I've fixed it in my side of the world.<br><br></div><div>I discovered it in a varnish3->4 POC I'm doing. When I saw varnish crashes, I got concerned, found that ticket, then found I was unable to register with Trac to update the ticket... so I fell back to updating the mailing list.<br><br></div><div>-Jason<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 4, 2015 at 11:26 PM, Geoff Simmons <span dir="ltr"><<a href="mailto:geoff@uplex.de" target="_blank">geoff@uplex.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA256<br>
<span class=""><br>
On 8/5/15 3:07 AM, Jason Price wrote:<br>
><br>
> if (req.url ~ "^((?!_product).)*$") {<br>
<br>
</span>Are you certain that this regex really does what you want it to do? It<br>
matches a URL with this sequence:<br>
<br>
* start of string, followed by<br>
* zero or more repetitions of<br>
  * a point at which "_product" does not match<br>
  * followed by any character<br>
* followed by end of string<br>
<br>
My poor imagination fails to come up with a real-world use case for that<br>
.<br>
<br>
For your example:<br>
<br>
> "/internal/v2/location?geocode=33.33,44.44&apiKey=hithere"<br>
<br>
... the regex matches the 'e' at the end of the string (try it at<br>
<a href="http://regex101.com/" rel="noreferrer" target="_blank">http://regex101.com/</a>).<br>
<br>
If I'm reading it right, your regex will match the empty string, or<br>
the final character of any non-empty string, provided that the final<br>
character is not preceded by "_product". Again, I suspect that that's<br>
not what you wanted.<br>
<span class=""><br>
> This ticket discusses the issue:<br>
> <a href="https://www.varnish-cache.org/trac/ticket/1576" rel="noreferrer" target="_blank">https://www.varnish-cache.org/trac/ticket/1576</a>   It's closed,<br>
> however the remedies mentioned don't help ("-p<br>
> thread_pool_stack=64k").  The ticket did mention a request for<br>
> minimal VCL to replicate.<br>
<br>
</span>That ticket is about regexen that send the PCRE matcher into deep<br>
recursion, and your regex might have also sent PCRE off the rails<br>
(negative lookahead within a zero-or-more quantifier could conceivably<br>
do that).<br>
<br>
I think you'd be much better off by rewriting your regex, first of all<br>
because I doubt that it accomplishes functionally what you're trying<br>
to do. But also because deep recursion in PCRE, or generally a regex<br>
that is expensive to match, is in my experience the one thing you can<br>
do in VCL to get Varnish to run slowly. Poorly written regexen in VCL<br>
can slow down whole web sites, I've seen it happen (if not to say:<br>
I've done it myself).<br>
<br>
<br>
HTH,<br>
Geoff<br>
- --<br>
UPLEX Systemoptimierung<br>
Scheffelstraße 32<br>
22301 Hamburg<br>
<a href="http://uplex.de/" rel="noreferrer" target="_blank">http://uplex.de/</a><br>
Mob: <a href="tel:%2B49-176-63690917" value="+4917663690917">+49-176-63690917</a><br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)<br>
<br>
iQIcBAEBCAAGBQJVwYJ2AAoJEOUwvh9pJNUR8vwQAIXX9dPtb8nocSv/Fcmt7Imo<br>
YBbryWrCtz+qakwGc1xMdmk2ul/OgSsZCpoViX9DfVyrxUBsShBtSTsq/bEaOccK<br>
YXBlwj6TlwX1x4uKLfZIT2mc7QOKz9qYEjyy8Aak/+ImaWC6aUs/6y3VhpdLgkuJ<br>
bm3Cncs8bWbT1C9KWwViaMNZ4kf19/x62PtGUaP1LzdD3Wqh1STSaKmqC7rN7W4g<br>
KguTX5jPiuMnGv2ZkT+RtfodCyItAw0b82lQ4Yo0XlA1IMQYFLoDiK95SQUlL0Ad<br>
/GGWwdUSVoXdQkwJiLH1QooFHqtUPHeF4nDQClwQ5E4pNThg6Za10vjrG57wjMGl<br>
TUT5OmAVY+tGn9i0kxlR0Kkg0T7Z1k3nMxpzt9ehhR6uyj99lRyytwc9TTD3jcp6<br>
/y2xOcdMVnbWZasznBO1HNF4ix5l4vas4eicsw2vwFSqk8Onsu/KhWKJ8ti2xH3W<br>
WsLXtAQYP/iQA2Ouvox7J5ynE/2CFABp23D3DurpBAhnCJ6FZMNYZ4hlrNdZ17Si<br>
Csu0JJwy+kZodNL4Lp8qWBDCfDWAHc+kSfXFpayYlva7NIrgZi6DOx/f/w71AcyR<br>
UjxYNFibtZisqUxrnofzpSu2jleIoID3bTVIhOyFNTaqRICQN0ONG8Btl7JBCr4r<br>
2Mj23zYEcQM6o4CA5JE8<br>
=X851<br>
-----END PGP SIGNATURE-----<br>
</blockquote></div><br></div>