Subject: Re: bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.

From: Thierry Volpiatto <[email-masked]>
Date: Sun, 08 Jan 2017 18:28:40 +0100

[email-masked] writes:

> Thierry Volpiatto <[email-masked]> writes:
>
>> Reproduce from emacs -Q:
>>
>> 1) require ffap.
>> 2) Open a file of about 560k containing only one line, e.g
>> "~/emacs.d/elpa/archives/archive-contents"
>> 3) M-: (ffap-guesser)
>>
>> Debugger entered--Lisp error: (error "Variable binding depth exceeds max-specpdl-size")
>>   looking-at("^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$")
> [...]
>>
>> This is reproductible from emacs-26 as well.
>
> The max-specpdl-size error looks like #24751 (I was planning to push the
> patch for that today), but as far as I know, that's only in emacs-26.
> emacs-25 and earlier correctly throw "stack overflow in regexp matcher".
> Unless you have REL_ALLOC enabled (which is the default for GNU/Linux
> distributions with the latest glibc), in which case any buffer search
> may crash emacs instead.  That's #24358, occurs in 25.1 (and probably
> earlier), but it's already fixed in the emacs-25 branch.  Also fixable
> by configuring with REL_ALLOC=no.

Good to know thanks.

However, this handle the problem with "Stack overflow in regexp matcher"
generally, but perhaps regexps such as `ffap-gopher-regexp` could be
avoided when possible in emacs source code.

IIUC regexps like "^.*\\(this\\|that etc...\\)" create an incredible
number of travels between bol and eol (which may sometimes be eob) and
lead to a stack overflow inevitably on long lines (perhaps not so long
in this case).

Thanks.

-- 
Thierry