Subject: bug#66151: 29.1.50; daemon crashing after X forwarding disconnects

From: Po Lu <[email-masked]>
Date: Fri, 19 Apr 2024 17:07:19 +0800

Eli Zaretskii <[email-masked]> writes:

>> Cc: [email-masked]
>> From: George P <[email-masked]>
>> Date: Sat, 13 Apr 2024 13:56:04 -0400
>> 
>> Thanks a lot for your efforts, but unfortunately the crash persists. I
>> have attached the same backtraces as before but on commit 17e26cf57e1.
>> 
>> Please let me know if you need more information.
>
> Thanks.
>
> Po Lu, how should we go about making some progress here?

Thanks.  My hands are quite full and will remain so into the next week,
but if this crude attempt to sidestep the crash works, it should suffice
until I establish why dead frames are still being retained in
Vfontset_table.  George?

diff --git a/src/fontset.c b/src/fontset.c
index d27fa22015e..d969e5f1180 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1366,10 +1366,11 @@ free_realized_fontsets (Lisp_Object base)
       if (CHAR_TABLE_P (this) && EQ (FONTSET_BASE (this), base))
 	{
 	  Fclear_face_cache (Qt);
-	  /* This is in case some Lisp calls this function and then
-	     proceeds with calling some other function, like font-at,
-	     which needs the basic faces.  */
-	  recompute_basic_faces (XFRAME (FONTSET_FRAME (this)));
+	  if (!FRAME_LIVE_P (XFRAME (FONTSET_FRAME (this))))
+	    /* This is in case some Lisp calls this function and then
+	       proceeds with calling some other function, like font-at,
+	       which needs the basic faces.  */
+	    recompute_basic_faces (XFRAME (FONTSET_FRAME (this)));
 	  break;
 	}
     }