Subject: bug#25679: 26.0.50; Emacs hangs for nested generics

From: Philipp Stephani <[email-masked]>
Date: Mon, 13 Feb 2017 09:30:14 +0000

Philipp Stephani <[email-masked]> schrieb am Fr., 10. Feb. 2017 um
20:28 Uhr:

>
> Create a file /tmp/Foo.java with the following content:
>
> class Foo {
>     void func(A<B<C>>> a, A<B<C>>> b, A<B<C>>> c, A<B<C>>> d, A<B<C>>> e,
> A<B<C>>> f, A<B<C>>> g, A<B<C>>> h, A<B<C>>> i, A<B<C>>> j, A<B<C>>> k) {}
> }
>
> Then open that file:
>
> emacs -Q /tmp/Foo.java
>
> Emacs hangs.  C-g also doesn't work.  GDB shows the culprit is a
> recursive invocation of
>
> "c-forward-<>-arglist-recur" (0x29dd1f00)
> "c-forward-<>-arglist" (0x29dd2530)
> "c-forward-name" (0x29dd2d40)
> "c-forward-type" (0x29dd3750)
>
> The actual top of the stack is often GC or a regex match.
> Seems the parsing of generic arguments has some exponential behavior.
> This is a regression since 24.3, where editing such files has no
> noticeable delay.
>
>
>
I've tried lowering font-lock-maximum-decoration, it also doesn't appear to
help. Even at level 1 Emacs hangs.

In general I've got quite a few reports about hangs and slowness in newer
versions of CC-Mode. Please make sure it never hangs, if necessary by
removing the more complex parsing algorithms and adding hard timeouts to
font locking.