unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#53203: Comment with lots of color codes crashes or hangs emacs in scss-mode
@ 2022-01-12  7:20 Colin
  2022-01-12 13:16 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Colin @ 2022-01-12  7:20 UTC (permalink / raw)
  To: 53203

Hi,


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 ;)








^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#53203: Comment with lots of color codes crashes or hangs emacs in scss-mode
  2022-01-12  7:20 bug#53203: Comment with lots of color codes crashes or hangs emacs in scss-mode Colin
@ 2022-01-12 13:16 ` Eli Zaretskii
  2022-01-13  7:00   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2022-01-12 13:16 UTC (permalink / raw)
  To: Colin; +Cc: 53203

> Date: Wed, 12 Jan 2022 17:20:24 +1000
> From: Colin <my.old.email.sucked@gmail.com>
> 
> 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)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#53203: Comment with lots of color codes crashes or hangs emacs in scss-mode
  2022-01-12 13:16 ` Eli Zaretskii
@ 2022-01-13  7:00   ` Lars Ingebrigtsen
  2022-01-13  8:58     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-13  7:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 53203, Colin

Eli Zaretskii <eliz@gnu.org> writes:

> 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)

Trying to understand the regexp used for scss here, I think that bit is
somewhat innocuous -- it just matches those words.

       ;; 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)
       "\\|::" (regexp-opt css-pseudo-element-ids t) "\\)"

But then we get:

       "\\(?:([^)]+)\\)?"
       (if (not sassy)
           "[^:{}()\n]*"
         (concat "[^:{}()\n#]*\\(?:" scss--hash-re "[^:{}()\n#]*\\)*"))
       "\\)*"

Which is a whole lot of backtracking, presumably exacerbated by the
previous ids bit of the regexp.

But I've repressed all I once knew about the scss language -- what is it
really trying to match here?  Anybody?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#53203: Comment with lots of color codes crashes or hangs emacs in scss-mode
  2022-01-13  7:00   ` Lars Ingebrigtsen
@ 2022-01-13  8:58     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2022-01-13  8:58 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53203, my.old.email.sucked

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Colin <my.old.email.sucked@gmail.com>,  53203@debbugs.gnu.org
> Date: Thu, 13 Jan 2022 08:00:18 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > 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)
> 
> Trying to understand the regexp used for scss here, I think that bit is
> somewhat innocuous -- it just matches those words.
> 
>        ;; 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)
>        "\\|::" (regexp-opt css-pseudo-element-ids t) "\\)"

I posted that because I saw this regexp in the backtrace obtained by
interrupting the infloop.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-13  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12  7:20 bug#53203: Comment with lots of color codes crashes or hangs emacs in scss-mode Colin
2022-01-12 13:16 ` Eli Zaretskii
2022-01-13  7:00   ` Lars Ingebrigtsen
2022-01-13  8:58     ` Eli Zaretskii

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).