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#50571: 28.0.50; Redisplay segfaults with empty face cache Date: Tue, 14 Sep 2021 16:33:43 +0300 Message-ID: <83a6kfcmdk.fsf@gnu.org> References: <87ilz4msha.fsf@tcd.ie> <831r5sea46.fsf@gnu.org> <87a6kggiz6.fsf@tcd.ie> <83bl4vcnsp.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12615"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 50571@debbugs.gnu.org To: contovob@tcd.ie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 14 15:44:59 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 1mQ8k6-000386-Pi for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Sep 2021 15:44:58 +0200 Original-Received: from localhost ([::1]:36768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ8k4-0000Ud-Je for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Sep 2021 09:44:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ8iy-0006vA-Tf for bug-gnu-emacs@gnu.org; Tue, 14 Sep 2021 09:43:48 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQ8ZX-00043l-JG for bug-gnu-emacs@gnu.org; Tue, 14 Sep 2021 09:34:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mQ8ZW-0003Iy-Bv for bug-gnu-emacs@gnu.org; Tue, 14 Sep 2021 09:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Sep 2021 13:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50571 X-GNU-PR-Package: emacs Original-Received: via spool by 50571-submit@debbugs.gnu.org id=B50571.163162643812694 (code B ref 50571); Tue, 14 Sep 2021 13:34:02 +0000 Original-Received: (at 50571) by debbugs.gnu.org; 14 Sep 2021 13:33:58 +0000 Original-Received: from localhost ([127.0.0.1]:48024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQ8ZS-0003Ig-FP for submit@debbugs.gnu.org; Tue, 14 Sep 2021 09:33:58 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:59186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQ8ZQ-0003IT-0m for 50571@debbugs.gnu.org; Tue, 14 Sep 2021 09:33:57 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53432) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ8ZK-0003vT-DG; Tue, 14 Sep 2021 09:33:50 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3356 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 1mQ8ZJ-0007Ku-EH; Tue, 14 Sep 2021 09:33:49 -0400 In-Reply-To: <83bl4vcnsp.fsf@gnu.org> (message from Eli Zaretskii on Tue, 14 Sep 2021 16:03:02 +0300) 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:214311 Archived-At: > Date: Tue, 14 Sep 2021 16:03:02 +0300 > From: Eli Zaretskii > Cc: 50571@debbugs.gnu.org > > Thanks, I see the reason now. It's because we allow to have arbitrary > Lisp to be registered in jit-lock-functions, and then that arbitrary > Lisp is called in the middle of redisplay, and in this case creates a > whole new frame with faces. As luck would have it, we decide right > there and then perform routine maintenance and release all the faces > on all the frames... > > I'm thinking about the best solution for this. Does the patch below give good results? diff --git a/src/frame.h b/src/frame.h index a8ad011..3dd7680 100644 --- a/src/frame.h +++ b/src/frame.h @@ -449,8 +449,8 @@ #define EMACS_FRAME_H /* Non-zero if this frame's faces need to be recomputed. */ bool_bf face_change : 1; - /* Non-zero if this frame's image cache cannot be freed because the - frame is in the process of being redisplayed. */ + /* Non-zero if this frame's image cache and face cache cannot be + freed because the frame is in the process of being redisplayed. */ bool_bf inhibit_clear_image_cache : 1; /* True when new_width or new_height were set by change_frame_size, diff --git a/src/xdisp.c b/src/xdisp.c index d30a685..2e72f6b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -16061,12 +16061,13 @@ #define AINC(a,i) \ if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f)) { - /* Don't allow freeing images for this frame as long - as the frame's update wasn't completed. This - prevents crashes when some Lisp that runs from - the various hooks or font-lock decides to clear - the frame's image cache, when the images in that - cache are referenced by the desired matrix. */ + /* Don't allow freeing images and faces for this + frame as long as the frame's update wasn't + completed. This prevents crashes when some Lisp + that runs from the various hooks or font-lock + decides to clear the frame's image cache and face + cache, when the images and faces in those caches + are referenced by the desired matrix. */ f->inhibit_clear_image_cache = true; redisplay_windows (FRAME_ROOT_WINDOW (f)); } diff --git a/src/xfaces.c b/src/xfaces.c index 2273fb4..aefed54 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -674,7 +674,8 @@ clear_face_cache (bool clear_fonts_p) { struct frame *f = XFRAME (frame); if (FRAME_WINDOW_P (f) - && FRAME_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS) + && FRAME_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS + && !f->inhibit_clear_image_cache) { clear_font_cache (f); free_all_realized_faces (frame);