bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49782: 28.0.50; set-fontset-font crashes in init (server)


From: Eli Zaretskii
Subject: bug#49782: 28.0.50; set-fontset-font crashes in init (server)
Date: Fri, 30 Jul 2021 17:10:38 +0300

> From: Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net>
> Date: Fri, 30 Jul 2021 14:54:19 +0200
> 
> I have a font initialization in my init file.  Reduced to a minimum
> example it does stuff like this:
> 
>     (mapc
>      (lambda (frame)
>        (set-fontset-font nil ?a "sans-serif" frame))
>      (frame-list))
> 
> This crashes when called from "emacsclient -a '' -c".
> 
> As a recipe:
> 
> * mkdir /tmp/test
> * Copy the above code into /tmp/test/.emacs
> * Run HOME=/tmp/test emacsclient -a '' -c
> 
> Note that "emacsclient -a emacs -c" does not crash.  There is something
> different between "-a ''" and "-a something".
> 
> Running gdb on the corresponding core file I get the typescript below.
> The problem seems to be in gdb frame #7, where even though there is a
> frame reported by frame-list, it does not have a valid fontset and so an
> assertion in FRAME_FONTSET(f) fails.

Probably because it's a daemon frame, which is not a GUI frame.

> I assume this is not intentional, otherwise how do I prevent the crash?

Put this code in server-after-make-frame-hook, I guess.

Does the patch below prevent the crash?

diff --git a/src/fontset.c b/src/fontset.c
index 332be6c..52c7e38 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1356,6 +1356,9 @@ check_fontset_name (Lisp_Object name, Lisp_Object *frame)
   int id;
   struct frame *f = decode_live_frame (*frame);
 
+  if (!FRAME_WINDOW_P (f))
+    error ("Can't use fontsets in non-GUI frames");
+
   XSETFRAME (*frame, f);
 
   if (EQ (name, Qt))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]