I also encountered this when I built it with different configuration. I attached updated patch with the correct number of arguments to 'similar_escape'. I also added preliminary documentation to the patch.
The "async" regression test consistently crashes on my FreeBSD box when built with -O2. It doesn't crash on another system I tried, and I think that's just luck, because this:
+ /* convert to regex pattern */ + datum = DirectFunctionCall1(similar_escape, CStringGetTextDatum(pattern));
... is calling a function that takes two arguments, but passing only one. The second argument is random junk, so similar_escape bombs when it does this: