From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#39892: 28.0.50; Crash when running async command Date: Thu, 05 Mar 2020 11:46:59 +0200 Message-ID: <83r1y7uoa4.fsf@gnu.org> References: <877e00976m.fsf@gmail.com> <83imjkw11p.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="84173"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 39892@debbugs.gnu.org To: rpluim@gmail.com, ravine.var@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 05 10:48:15 2020 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 1j9n70-000Loj-KO for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Mar 2020 10:48:14 +0100 Original-Received: from localhost ([::1]:45904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9n6z-0007Ou-HL for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Mar 2020 04:48:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35851) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9n6p-0007NC-Pk for bug-gnu-emacs@gnu.org; Thu, 05 Mar 2020 04:48:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9n6o-0005Gr-Lu for bug-gnu-emacs@gnu.org; Thu, 05 Mar 2020 04:48:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36201) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j9n6o-0005Gc-IK for bug-gnu-emacs@gnu.org; Thu, 05 Mar 2020 04:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j9n6o-00040t-G0 for bug-gnu-emacs@gnu.org; Thu, 05 Mar 2020 04:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Mar 2020 09:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39892 X-GNU-PR-Package: emacs Original-Received: via spool by 39892-submit@debbugs.gnu.org id=B39892.158340164515382 (code B ref 39892); Thu, 05 Mar 2020 09:48:02 +0000 Original-Received: (at 39892) by debbugs.gnu.org; 5 Mar 2020 09:47:25 +0000 Original-Received: from localhost ([127.0.0.1]:42174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j9n6C-000402-RH for submit@debbugs.gnu.org; Thu, 05 Mar 2020 04:47:25 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j9n6B-0003zj-B3 for 39892@debbugs.gnu.org; Thu, 05 Mar 2020 04:47:23 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:41125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j9n66-0004G1-4m; Thu, 05 Mar 2020 04:47:18 -0500 Original-Received: from [176.228.60.248] (port=4616 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1j9n65-0002HG-FW; Thu, 05 Mar 2020 04:47:17 -0500 In-Reply-To: <83imjkw11p.fsf@gnu.org> (message from Eli Zaretskii on Wed, 04 Mar 2020 18:13:38 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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:176891 Archived-At: > Date: Wed, 04 Mar 2020 18:13:38 +0200 > From: Eli Zaretskii > Cc: ravine.var@gmail.com, 39892@debbugs.gnu.org > > > for (i = 0; i < size; i++) > > { > > Lisp_Object rfont_def = AREF (vec, i); > > Lisp_Object font_def = RFONT_DEF_FONT_DEF (rfont_def); > > > > 'vec' at that point is > > > > [ > > [nil [# 144 nil] nil 0] > > nil > > [nil [# 0 0] nil 2] > > ] > > > > and i == 1, so rfont_def ends up as nil. > > > > How did that 'nil' get in there? > > I don't know. The code seems to expect one nil as the last element of > the vector, but not in the middle. Note that the commentary at the > beginning of fontset.c explains when RFONT_DEF may be nil. How about the patch below? It works for me, and seems to be TRT in general, since it makes the code more defensive in the face of possible nil values in that vector, which are legitimate according to my reading of the commentary at the beginning of fontset.c. CC'ing Handa-san in the hope that he might have comments or suggestions. Btw, in general using such fontset customizations make little sense, since you are in effect telling Emacs this font covers all of the Unicode, which cannot be true. Not specifying the registry is also not recommended, definitely not for such large ranges of codepoints. > Btw, U+E9F8 is a PUA character; how did it get into a context where we > are trying to display it? I'd still like to know the answer to this. It seems like something fishy is going on in the original use case that requires us to try to display this PUA codepoint. Here's the patch I propose to install on the emacs-27 branch: diff --git a/src/fontset.c b/src/fontset.c index bca9452..c2bb8b2 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -367,8 +367,14 @@ fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Objec static int fontset_compare_rfontdef (const void *val1, const void *val2) { - return (RFONT_DEF_SCORE (*(Lisp_Object *) val1) - - RFONT_DEF_SCORE (*(Lisp_Object *) val2)); + Lisp_Object v1 = *(Lisp_Object *) val1, v2 = *(Lisp_Object *) val2; + if (NILP (v1) && NILP (v2)) + return 0; + else if (NILP (v1)) + return INT_MIN; + else if (NILP (v2)) + return INT_MAX; + return (RFONT_DEF_SCORE (v1) - RFONT_DEF_SCORE (v2)); } /* Update a cons cell which has this form: @@ -400,6 +406,8 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) for (i = 0; i < size; i++) { Lisp_Object rfont_def = AREF (vec, i); + if (NILP (rfont_def)) + continue; Lisp_Object font_def = RFONT_DEF_FONT_DEF (rfont_def); Lisp_Object font_spec = FONT_DEF_SPEC (font_def); int score = RFONT_DEF_SCORE (rfont_def) & 0xFF;