Subject: Re: bug#22146: Stack overflow in reftex-parse-all

From: Mosè Giordano <[email-masked]>
Date: Sat, 12 Dec 2015 00:36:53 +0100

Hi Nils,

2015-12-11 22:03 GMT+01:00 Nils Kanning <[email-masked]>:
> Dear all,
>
> I encounter the error "Stack overflow in regexp matcher" if I apply the
> function reftex-parse-all to the following file:
>
> \documentclass{article}
> \begin{document}
> [\}
> foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
> ...
> foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
> \end{document}
>
> Here ... stands for 500 copies of the line above. The file can be
> compiled successfully with pdflatex.
>
> I am using the Debian packages emacs24 24.5+1-3 and auctex 11.88-1.1.
> The same error also occurs with different versions.

We've recently released AUCTeX 11.89, you can grab it from ELPA ;-)

> In case you are wondering, the non-matching brackets [\} appear for
> example in physics as so-called "super Lie brackets".

Thanks for taking the time to report this bug, I can reproduce it.
The culprit is the

    (re-search-forward (reftex-everything-regexp) nil t)

within the `reftex-with-special-syntax' macro in
`reftex-parse-from-file' function.  Actually in the code it is called
as

    (re-search-forward regexp nil t)

I wrote the above line for ease of reproduction.

Of course `reftex-everything-regexp' is an undocumented function that
returns one of two undocumented variables.  I can reproduce the bug
only if `reftex-support-index' is non-nil, so in the end the culprit
is `reftex-everything-regexp'.

There is a simple workaround you can put in your code: close the
brackets, also in a comment is fine:

    [\} % ]

But I don't know how to really fix the bug, it's too late for me to
decrypt that regexp now.  Having a clue of what it should *exactly*
match would be of great help.

Bye,
Mosè