From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#49782: 28.0.50; set-fontset-font crashes in init (server) Date: Fri, 30 Jul 2021 17:10:38 +0300 Message-ID: <83eebfrixt.fsf@gnu.org> References: <87mtq4rmh0.fsf@arrian.i-did-not-set--mail-host-address--so-tickle-me> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22085"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49782@debbugs.gnu.org To: Benjamin Riefenstahl Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 30 16:12:23 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9TFO-0005Xa-3c for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 30 Jul 2021 16:12:22 +0200 Original-Received: from localhost ([::1]:44192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9TFM-0003my-TC for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 30 Jul 2021 10:12:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9TF4-0003mM-Jb for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2021 10:12:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m9TF4-0006pq-Bs for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2021 10:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m9TF3-0005PV-Vi for bug-gnu-emacs@gnu.org; Fri, 30 Jul 2021 10:12:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Jul 2021 14:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49782 X-GNU-PR-Package: emacs Original-Received: via spool by 49782-submit@debbugs.gnu.org id=B49782.162765427820743 (code B ref 49782); Fri, 30 Jul 2021 14:12:01 +0000 Original-Received: (at 49782) by debbugs.gnu.org; 30 Jul 2021 14:11:18 +0000 Original-Received: from localhost ([127.0.0.1]:60642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9TEM-0005OV-3O for submit@debbugs.gnu.org; Fri, 30 Jul 2021 10:11:18 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41148) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m9TEK-0005OH-Qz for 49782@debbugs.gnu.org; Fri, 30 Jul 2021 10:11:17 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:40264) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9TEF-000690-Hz; Fri, 30 Jul 2021 10:11:11 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1212 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9TEC-0000Hn-9s; Fri, 30 Jul 2021 10:11:11 -0400 In-Reply-To: <87mtq4rmh0.fsf@arrian.i-did-not-set--mail-host-address--so-tickle-me> (message from Benjamin Riefenstahl on Fri, 30 Jul 2021 14:54:19 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:210912 Archived-At: > From: Benjamin Riefenstahl > 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))