Subject: bug#51577: 27.2; Regression: reproducible hang with face functions

From: Eli Zaretskii <[email-masked]>
Date: Thu, 04 Nov 2021 21:01:59 +0200

> From: Lars Ingebrigtsen <[email-masked]>
> Cc: Drew Adams <[email-masked]>,  [email-masked]
> Date: Thu, 04 Nov 2021 19:15:23 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > And how does your code differ from this:
> >
> >   (while t nil)
> >
> > Or would you consider it a bug that Emacs doesn't detect the infinite
> > while-loop, either?
> 
> We do try to detect loops in other situations (to avoid hangs).  This is
> in redisplay code, though (I think?), so perhaps it would be
> prohibitively expensive to try to detect loops here?

First, since this is triggered by redisplay, any errors must be
"silent": we log an error message in *Messages* and otherwise silently
do nothing.  Which in this case would mean the problematic face will
not be applied.  Not sure this is better than inflooping.

As for detecting loops: it could be tricky.  It is easy enough to
detect simple loops such as the one in this case, where a face
inherits directly from itself, and the value of the :inherit attribute
is the symbol of a face.  But inheritance loops could be less simple:
a face could inherit from itself indirectly, and the value of the
attribute could be a list, not a named face.  Detecting loops in those
cases would require recording face specs/names we already saw in some
list, and each time we get an :inherit attribute, check if its value
is already in the list.  Is that worth our while, if the result will
be a silent error message in *Messages*?