From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#18162: 24.3.92; segfault on null face pointer in face_for_char Date: Sun, 03 Aug 2014 18:04:29 +0300 Message-ID: <83bns1r4w2.fsf@gnu.org> References: <6ewqatjen6.fsf@just-testing.permabit.com> <838un8sqeo.fsf@gnu.org> <83vbqbqtc1.fsf@gnu.org> <0917D61C-D040-44A7-B7D6-B4AD5BDB0BEA@permabit.com> <83mwbnqilz.fsf@gnu.org> <83iombqclz.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1407078332 11691 80.91.229.3 (3 Aug 2014 15:05:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Aug 2014 15:05:32 +0000 (UTC) Cc: 18162@debbugs.gnu.org To: Ken Raeburn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 03 17:05:24 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XDxLg-0002iR-0M for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Aug 2014 17:05:24 +0200 Original-Received: from localhost ([::1]:48227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDxLf-0006Ts-2H for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Aug 2014 11:05:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDxLW-0006St-8X for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2014 11:05:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XDxLM-0005ws-TM for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2014 11:05:14 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDxLM-0005wg-RD for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2014 11:05:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XDxLM-0007Hh-DK for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2014 11:05:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Aug 2014 15:05:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18162 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18162-submit@debbugs.gnu.org id=B18162.140707827527939 (code B ref 18162); Sun, 03 Aug 2014 15:05:04 +0000 Original-Received: (at 18162) by debbugs.gnu.org; 3 Aug 2014 15:04:35 +0000 Original-Received: from localhost ([127.0.0.1]:56094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XDxKs-0007GY-Lg for submit@debbugs.gnu.org; Sun, 03 Aug 2014 11:04:35 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:64076) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XDxKp-0007GH-EI for 18162@debbugs.gnu.org; Sun, 03 Aug 2014 11:04:33 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0N9Q00A00K0K6000@a-mtaout22.012.net.il> for 18162@debbugs.gnu.org; Sun, 03 Aug 2014 18:04:24 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N9Q00A9RKJC6Y10@a-mtaout22.012.net.il>; Sun, 03 Aug 2014 18:04:24 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92073 Archived-At: > From: Ken Raeburn > Date: Sun, 3 Aug 2014 02:51:38 -0400 > Cc: 18162@debbugs.gnu.org > > On Aug 2, 2014, at 08:50, Eli Zaretskii wrote: > > Moreover, even if I force the call to clear_font_cache by invoking > > clear-font-cache in the progn, I don't see a crash, and the use count > > of the frame's face cache is not zero. > > > > So one way of tracking this down would be to put a breakpoint in > > Fclear_face_cache, and when it breaks, step through the function until > > it assigns the frame pointer to 'f', and put a watchpoint on > > f->face_cache->used, to see which code zeroes it. My guess would be > > that some code calls free_realized_faces (I misremembered earlier: > > clear_face_cache doesn't do that). > > In the code I'm looking at, clear_face_cache can call free_all_realized_faces, but only if FRAME_DISPLAY_INFO(f)->n_fonts is larger than 10 for some frame. Yes, I meant clear_face_cache doesn't do that directly. And since free_realized_faces is called from several other places, it's best not to assume this particular call is necessarily the culprit. > (And either clear_fonts_p is set, or you've made over 500 calls since the last font cache cleaning.) In my first evaluation of the lisp code I gave, the n_fonts field had the value 7; on the second evaluation it had the value 12, the cache got cleared, the null pointer was stored, and Emacs segfaulted. > > I've done next to nothing with fonts and faces in Emacs source code, so I'm not sure what a good way is to drive up the number. If I run my test again without list-faces-display, the font counts I'm seeing are first 4 and then 7 for repeated evaluations, as displayed via gdb breakpoint commands. If I split the window with C-x 2 then the count goes up to 8 (new inactive mode line?). Reducing the font size (C-x -) made it jump to 14, and 15 on repeated evaluations, without triggering the problem, but when I set the font size back (C-x +) and evaluated the expression one more time, I got the crash. Does the patch below help? === modified file 'src/fontset.c' --- src/fontset.c 2014-01-01 07:43:34 +0000 +++ src/fontset.c 2014-08-03 15:00:11 +0000 @@ -1860,6 +1860,8 @@ DEFUN ("internal-char-font", Finternal_c return Qnil; if (!FRAME_WINDOW_P (f)) return Qnil; + if (FRAME_FACE_CACHE (f)->used == 0) + recompute_basic_faces (f); face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil); face = FACE_FROM_ID (f, face_id); if (face->font)