Subject: Re: bug#39865: 28.0.50; Emacs crash

From: Robert Pluim <[email-masked]>
Date: Tue, 10 Mar 2020 16:15:09 +0100

>>>>> On Tue, 10 Mar 2020 16:52:04 +0200, Eli Zaretskii <[email-masked]> said:

    >> From: Robert Pluim <[email-masked]>
    >> Cc: Vinicius José Latorre <[email-masked]>,
    >> [email-masked]
    >> Date: Tue, 10 Mar 2020 15:29:44 +0100
    >> 
    >> >> I think that emacs should be more robust about this and do not crash for any bad value.
    >> 
    Eli> I agree.  It is not a bad value, we just couldn't yet find a way of
    Eli> switching the font-backend.
    >> 
    >> Eli, would you accept a patch for emacs-27 that signals a user-error
    >> if trying to set a font-backend thatʼs not supported by the running
    >> emacs? Or that ignores it (with a message)?

    Eli> In general, yes; but I'd need to see the patch.

diff --git a/src/frame.c b/src/frame.c
index 51fc78ab70..3b0174cea9 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -4090,6 +4090,21 @@ gui_set_frame_parameters (struct frame *f, Lisp_Object alist)
 	}
       else
 	{
+          if (EQ (prop, Qfont_backend))
+            {
+              Lisp_Object tail = val;
+              Lisp_Object backend;
+              FOR_EACH_TAIL_SAFE (tail)
+                {
+                  backend = XCAR (tail);
+                  if (! c_symbol_p (XSYMBOL (backend)))
+                    {
+                      AUTO_STRING (format, "Unsupported font-backend: \"%s\"");
+                      xsignal1 (Quser_error, CALLN (Fformat, format, backend));
+                    }
+                }
+            }
+
 	  register Lisp_Object param_index, old_value;
 
 	  old_value = get_frame_param (f, prop);

    Eli> AFAIU, the problem in this case wasn't that the backend wasn't
    Eli> supported, it was that it was changed in the middle of a session.

Setting font-backend to a supported value with default-frame-alist
in .emacs should work, and does for me in master, at least switching
from 'ftcrhb' to 'ftcr'. Switching from 'ftcrhb' to 'xft' crashes.

Hmm, switching to 'x' also crashes. But I can create a new frame with
'x' as font-backend.

Robert