Subject: Re: bug#71176: 30.0.50; Segmentation fault (SIGSEGV) in TTY+emacsclient, default_face is nil

From: Eli Zaretskii <[email-masked]>
Date: Sat, 25 May 2024 21:07:06 +0300

> Cc: [email-masked]
> Date: Sat, 25 May 2024 20:48:07 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> And also, please try the patch below.

Sorry, that is not enough.  Please try the patch below instead.

diff --git a/src/xdisp.c b/src/xdisp.c
index 7a00b29..47675fc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13377,8 +13377,10 @@ echo_area_display (bool update_frame_p)
   w = XWINDOW (mini_window);
   f = XFRAME (WINDOW_FRAME (w));
 
-  /* Don't display if frame is invisible or not yet initialized.  */
-  if (!FRAME_REDISPLAY_P (f) || !f->glyphs_initialized_p)
+  /* Don't display if frame is invisible or not yet initialized or
+     if redisplay is inhibited.  */
+  if (!FRAME_REDISPLAY_P (f) || !f->glyphs_initialized_p
+      || !NILP (Vinhibit_redisplay))
     return;
 
 #ifdef HAVE_WINDOW_SYSTEM
diff --git a/src/xfaces.c b/src/xfaces.c
index 5192b22..340f181 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4246,6 +4246,12 @@ DEFUN ("internal-merge-in-global-face", Finternal_merge_in_global_face,
       /* This can be NULL (e.g., in batch mode).  */
       if (oldface)
 	{
+	  /* In some cases, realize_face below can call Lisp, which could
+             trigger redisplay.  But we are in the process of realizing
+             the default face, and therefore are not ready to do display.  */
+	  specpdl_ref count = SPECPDL_INDEX ();
+	  specbind (Qinhibit_redisplay, Qt);
+
 	  /* Ensure that the face vector is fully specified by merging
 	     the previously-cached vector.  */
 	  memcpy (attrs, oldface->lface, sizeof attrs);
@@ -4291,6 +4297,8 @@ DEFUN ("internal-merge-in-global-face", Finternal_merge_in_global_face,
 			      gvec[LFACE_BACKGROUND_INDEX]);
 	      Fmodify_frame_parameters (frame, arg);
 	    }
+
+	  unbind_to (count, Qnil);
 	}
     }