Subject: Re: bug#53203: Comment with lots of color codes crashes or hangs emacs in scss-mode

From: Eli Zaretskii <[email-masked]>
Date: Wed, 12 Jan 2022 15:16:57 +0200

> Date: Wed, 12 Jan 2022 17:20:24 +1000
> From: Colin <[email-masked]>
> 
> I have the following snippet in example.scss file:
> 
> ```
> 
> /*
> #ffffff #ffffff
> #ffffff #ffffff
> #ffffff #ffffff
> #ffffff #ffffff
> #ffffff #ffffff
> */
> ```
> 
> On opening the file with emacs -Q (27.1 and a fresh build of git master 
> (29.0.50), emacs hangs.
> 
> If I remove one/two lines, it appears to burn some CPU and then work, so 
> it looks like an exponential search or something.
> 
> For now I'll remove the snippet from my code, but an interesting bug 
> nonetheless ;)

It seems to infloop in JIT font-lock, and the culprit seems to be this
part of font-lock-keywords:

       ;; Even though pseudo-elements should be prefixed by ::, a
       ;; single colon is accepted for backward compatibility.
       "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
                                       css-pseudo-element-ids)
                               t)