From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Lumby Newsgroups: gmane.emacs.bugs Subject: bug#6593: emacs-23.2 crashes in get_glyph_face_and_encoding with a null face returned by FACE_FROM_ID(0) Date: Fri, 9 Jul 2010 09:54:55 -0400 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_b999fecc-2759-43c5-8ac5-58aab71ecab3_" X-Trace: dough.gmane.org 1278693363 18206 80.91.229.12 (9 Jul 2010 16:36:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 9 Jul 2010 16:36:03 +0000 (UTC) To: 6593@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 09 18:36:02 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OXGYN-00089G-Ro for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Jul 2010 18:35:56 +0200 Original-Received: from localhost ([127.0.0.1]:52121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXGYN-0000X6-07 for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Jul 2010 12:35:55 -0400 Original-Received: from [140.186.70.92] (port=48905 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXGSk-0006qk-L3 for bug-gnu-emacs@gnu.org; Fri, 09 Jul 2010 12:30:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OXGSi-0006KL-VS for bug-gnu-emacs@gnu.org; Fri, 09 Jul 2010 12:30:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56769) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OXGSi-0006KH-Tm for bug-gnu-emacs@gnu.org; Fri, 09 Jul 2010 12:30:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OXG2Z-00059f-2i; Fri, 09 Jul 2010 12:03:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: John Lumby Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Jul 2010 16:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 6593 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: Original-Received: via spool by submit@debbugs.gnu.org id=B.127869134619777 (code B ref -1); Fri, 09 Jul 2010 16:03:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Jul 2010 16:02:26 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OXG1w-00058w-Ov for submit@debbugs.gnu.org; Fri, 09 Jul 2010 12:02:26 -0400 Original-Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OXE3E-0003d2-Nq for submit@debbugs.gnu.org; Fri, 09 Jul 2010 09:55:38 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:58826) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OXE39-0001ci-Eo for submit@debbugs.gnu.org; Fri, 09 Jul 2010 09:55:31 -0400 Original-Received: from [140.186.70.92] (port=34950 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXE33-0006hD-7L for bug-gnu-emacs@gnu.org; Fri, 09 Jul 2010 09:55:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OXE2b-0002rc-MU for bug-gnu-emacs@gnu.org; Fri, 09 Jul 2010 09:55:25 -0400 Original-Received: from col0-omc1-s13.col0.hotmail.com ([65.55.34.23]:47610) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OXE2b-0002rR-DA for bug-gnu-emacs@gnu.org; Fri, 09 Jul 2010 09:54:57 -0400 Original-Received: from COL116-W33 ([65.55.34.7]) by col0-omc1-s13.col0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 9 Jul 2010 06:54:55 -0700 X-Originating-IP: [70.31.48.125] Importance: Normal X-OriginalArrivalTime: 09 Jul 2010 13:54:55.0866 (UTC) FILETIME=[4FF745A0:01CB1F6E] X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP4, XP SP1+ X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Mailman-Approved-At: Fri, 09 Jul 2010 12:02:23 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 09 Jul 2010 12:03:03 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Fri, 09 Jul 2010 12:35:23 -0400 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:38317 Archived-At: --_b999fecc-2759-43c5-8ac5-58aab71ecab3_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable paste this text into any lisp-interaction buffer e.g. *scratch*=2C positi= on cursor at end=2C and press Ctl-X Ctl-E (progn (modify-frame-parameters (selected-frame) '((menu-bar-lines . 0))) (set-face-font 'modeline "-misc-fixed-medium-r-normal--13-120-75-75-c-70-is= o8859-1") (face-set-after-frame-default (selected-frame)) (set-face-background 'defa= ult (cdr (assoc 'background-color (frame-parameters (selected-frame))))) (s= et-face-background 'fringe (cdr (assoc 'background-color (frame-parameters = (selected-frame))))) (set-face-foreground 'default (cdr (assoc 'foreground-= color (frame-parameters (selected-frame))))) (server-start)) I get a crash in get_glyph_face_and_encoding.=20 It did not happen in 23.1 I started emacs with something like emacs --name=3Dsawlist --title=3Dsawlist -ms "#14892b" -cr red -fn "-Misc-F= ixed-bold-R-*--15-*-*-*-C-90-ISO8859-1" -bg "#E0EDED" -fg "#751503" -q -loa= d sawlist.el I can send my sawlist.el if needed I obtained a core file after rebuilding to get the debugging information an= d here is the relevant piece (gdb) bt #0 0x00d57424 in __kernel_vsyscall () #1 0x00876006 in kill () at ../sysdeps/unix/syscall-template.S:82 #2 0x0810fe76 in fatal_error_signal (sig=3D11) at emacs.c:402 #3 #4 get_glyph_face_and_encoding (f=3D0x920c4f0=2C glyph=3D0x946b9a0=2C char= 2b=3D0xbfbeb890=2C two_byte_p=3D0xbfbeb85c) at xdisp.c:19511 #5 0x0806bc58 in fill_glyph_string (s=3D0xbfbeb8b0=2C face_id=3D0=2C start= =3D=2C end=3D1=2C overlaps=3D0) at xdisp.c:19681 #6 0x0806c68b in draw_glyphs (w=3D0x920c670=2C x=3D27=2C row=3D0x93fa530= =2C area=3DTEXT_AREA=2C start=3D0=2C end=3D1=2C hl=3DDRAW_NORMAL_TEXT=2C ov= erlaps=3D0) at xdisp.c:20297 This patch (below) fixes one obvious mistake (but not the cause) and also w= orks around the problem. This mistake is that the assert is located after = the dereference of the face pointer - should be before. But that just ch= anges the crash to an assert failure. The workaround to is to try all oth= er faces cached on the frame. I don't know what the correct fix is for t= he default face being null. John Lumby --- src/dispextern.h.orig 2010-04-03 18:26:13.000000000 -0400 +++ src/dispextern.h 2010-07-08 11:17:41.000000000 -0400 @@ -1664=2C12 +1664=2C19 @@ struct face_cache else \ (void) 0 =20 +/* search for the first usable cached face on frame F=2C + or null if such a face doesn't exist. */ + +struct face *try_all_cached_faces(struct frame *f)=3B + /* Return a pointer to the face with ID on frame F=2C or null if such a - face doesn't exist. */ + face doesn't exist. But try *all* faces cached for this frame before = giving up */ =20 #define FACE_FROM_ID(F=2C ID) \ (((unsigned) (ID) < FRAME_FACE_CACHE (F)->used) \ - ? FRAME_FACE_CACHE (F)->faces_by_id[ID] \ + ? (FRAME_FACE_CACHE (F)->faces_by_id[ID] ? FRAME_FACE_CACHE (F)->= faces_by_id[ID] : \ + try_all_cached_faces(F) \ + ) \ : NULL) =20 #ifdef HAVE_WINDOW_SYSTEM --- src/xdisp.c.orig 2010-04-05 10:05:48.000000000 -0400 +++ src/xdisp.c 2010-07-08 11:23:35.000000000 -0400 @@ -19489=2C6 +19489=2C22 @@ get_char_face_and_encoding (f=2C c=2C face_i } =20 =20 +/* search for the first usable cached face on frame F=2C + or null if such a face doesn't exist. */ + +struct face *try_all_cached_faces(struct frame *f) +{ + struct face *local_face =3D 0=3B + int ix=2C used=3B + + used =3D FRAME_FACE_CACHE(f)->used=3B + for (ix=3D0=3B ((ixfaces_by_id[ix]=3B + } + + return local_face=3B +} + /* Get face and two-byte form of character glyph GLYPH on frame F. The encoding of GLYPH->u.ch is returned in *CHAR2B. Value is a pointer to a realized face that is ready for display. */ @@ -19505=2C6 +19521=2C9 @@ get_glyph_face_and_encoding (f=2C glyph=2C c xassert (glyph->type =3D=3D CHAR_GLYPH)=3B face =3D FACE_FROM_ID (f=2C glyph->face_id)=3B =20 + /* Make sure X resources of the face are allocated. */ + xassert (face !=3D NULL)=3B + if (two_byte_p) *two_byte_p =3D 0=3B =20 @@ -19518=2C8 +19537=2C6 @@ get_glyph_face_and_encoding (f=2C glyph=2C c STORE_XCHAR2B (char2b=2C 0=2C 0)=3B } =20 - /* Make sure X resources of the face are allocated. */ - xassert (face !=3D NULL)=3B PREPARE_FACE_FOR_DISPLAY (f=2C face)=3B return face=3B } =20 Your Photo on Bing.ca: You Could WIN on Canada Day! Submit a Photo Now! = =20 _________________________________________________________________ Learn more ways to connect with your buddies now http://go.microsoft.com/?linkid=3D9734388= --_b999fecc-2759-43c5-8ac5-58aab71ecab3_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable  =3Bpaste this text into any lisp-interaction buffer e.g. *scratch*=2C&= nbsp=3B position cursor at end=2C and press Ctl-X Ctl-E


(progn (= modify-frame-parameters (selected-frame) '((menu-bar-lines . 0)))
(set-f= ace-font 'modeline "-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-= 1")
(face-set-after-frame-default (selected-frame)) (set-face-backgroun= d 'default (cdr (assoc 'background-color (frame-parameters (selected-frame)= )))) (set-face-background 'fringe (cdr (assoc 'background-color (frame-para= meters (selected-frame))))) (set-face-foreground 'default (cdr (assoc 'fore= ground-color (frame-parameters (selected-frame))))) (server-start))

=

I get a crash in get_glyph_face_and_encoding. =3B


It= did not happen in 23.1

I started emacs with something like
emacs= --name=3Dsawlist --title=3Dsawlist -ms "#14892b" -cr red -fn "-Misc-Fixed-= bold-R-*--15-*-*-*-C-90-ISO8859-1" -bg "#E0EDED" -fg "#751503" -q -load saw= list.el

I can send my sawlist.el =3B if needed

I obtained= a core file after rebuilding to get the debugging information and here is = the relevant piece
(gdb) bt
#0 =3B 0x00d57424 in __kernel_vsyscal= l ()
#1 =3B 0x00876006 in kill () at ../sysdeps/unix/syscall-templat= e.S:82
#2 =3B 0x0810fe76 in fatal_error_signal (sig=3D11) at emacs.c= :402
#3 =3B <=3Bsignal handler called>=3B
#4 =3B get_glyp= h_face_and_encoding (f=3D0x920c4f0=2C glyph=3D0x946b9a0=2C char2b=3D0xbfbeb= 890=2C two_byte_p=3D0xbfbeb85c) at xdisp.c:19511
#5 =3B 0x0806bc58 i= n fill_glyph_string (s=3D0xbfbeb8b0=2C face_id=3D0=2C start=3D<=3Bvalue o= ptimized out>=3B=2C end=3D1=2C overlaps=3D0) at xdisp.c:19681
#6 = =3B 0x0806c68b in draw_glyphs (w=3D0x920c670=2C x=3D27=2C row=3D0x93fa530= =2C area=3DTEXT_AREA=2C start=3D0=2C end=3D1=2C hl=3DDRAW_NORMAL_TEXT=2C ov= erlaps=3D0)
 =3B =3B =3B at xdisp.c:20297



Thi= s patch (below) fixes one obvious mistake (but not the cause) and also work= s around the problem.  =3BThis mistake is that the assert is located af= ter the dereference of the face pointer  =3B- should be before.  = =3B But that just changes the crash to an assert failure.  =3B The work= around to is to try all other faces cached on the frame.  =3B  =3BI= don't know what the correct fix is for the default face being null.

John Lumby


--- src/dispextern.h.orig 2010-04-03 18:26:13.00= 0000000 -0400
+++ src/dispextern.h 2010-07-08 11:17:41.000000000 -0400@@ -1664=2C12 +1664=2C19 @@ struct face_cache
else \
= (void) 0

+/* search for the first usable cached face on frame F= =2C
+ or null if such a face doesn't exist. */
+
+struct face *= try_all_cached_faces(struct frame *f)=3B
+
/* Return a pointer to th= e face with ID on frame F=2C or null if such a
- face doesn't exist. = */
+ face doesn't exist. But try *all* faces cached for this frame b= efore giving up */

#define FACE_FROM_ID(F=2C ID) \
((= (unsigned) (ID) <=3B FRAME_FACE_CACHE (F)->=3Bused) \
- ? FRAME= _FACE_CACHE (F)->=3Bfaces_by_id[ID] \
+ ? (FRAME_FACE_CACHE (= F)->=3Bfaces_by_id[ID] ? FRAME_FACE_CACHE (F)->=3Bfaces_by_id[ID] : \+ try_all_cached_faces(F) \
+ ) \
: NUL= L)

#ifdef HAVE_WINDOW_SYSTEM

--- src/xdisp.c.orig =3B&n= bsp=3B =3B 2010-04-05 10:05:48.000000000 -0400
+++ src/xdisp.c = =3B =3B =3B 2010-07-08 11:23:35.000000000 -0400
@@ -19489=2C6 +1= 9489=2C22 @@ get_char_face_and_encoding (f=2C c=2C face_i
 =3B}
&= nbsp=3B
 =3B
+/* search for the first usable cached face on frame= F=2C
+ =3B =3B or null if such a face doesn't exist. =3B */=
+
+struct face *try_all_cached_faces(struct frame *f)
+{
+&nbs= p=3B struct face *local_face =3D 0=3B
+ =3B int ix=2C used=3B
++ =3B used =3D FRAME_FACE_CACHE(f)->=3Bused=3B
+ =3B for (ix= =3D0=3B ((ix<=3Bused) &=3B&=3B (local_face =3D=3D (struct face *)0)= )=3B ix++) {
+ =3B =3B =3B =3B local_face =3D =3B FR= AME_FACE_CACHE(f)->=3Bfaces_by_id[ix]=3B
+ =3B }
+
+ =3B= return local_face=3B
+}
+
 =3B/* Get face and two-byte form o= f character glyph GLYPH on frame F.
 =3B =3B =3B The encodin= g of GLYPH->=3Bu.ch is returned in *CHAR2B. =3B Value is
 =3B&= nbsp=3B =3B a pointer to a realized face that is ready for display.&nbs= p=3B */
@@ -19505=2C6 +19521=2C9 @@ get_glyph_face_and_encoding (f=2C gl= yph=2C c
 =3B =3B xassert (glyph->=3Btype =3D=3D CHAR_GLYPH)= =3B
 =3B =3B face =3D FACE_FROM_ID (f=2C glyph->=3Bface_id)=3B=
 =3B
+ =3B /* Make sure X resources of the face are allocate= d. =3B */
+ =3B xassert (face !=3D NULL)=3B
+
 =3B&nbs= p=3B if (two_byte_p)
 =3B =3B =3B =3B *two_byte_p =3D 0= =3B
 =3B
@@ -19518=2C8 +19537=2C6 @@ get_glyph_face_and_encoding = (f=2C glyph=2C c
 =3B =3B =3B =3B STORE_XCHAR2B (char2b= =2C 0=2C 0)=3B
 =3B =3B =3B =3B }
 =3B
- = =3B /* Make sure X resources of the face are allocated. =3B */
-&nbs= p=3B xassert (face !=3D NULL)=3B
 =3B =3B PREPARE_FACE_FOR_DISPL= AY (f=2C face)=3B
 =3B =3B return face=3B
 =3B}




Your Photo on Bing.ca: You Could WIN on Canada Da= y! Submit a Photo Now= !

Enter for a chance to get your town photo on = Bing.ca! Submit a Photo Now! = --_b999fecc-2759-43c5-8ac5-58aab71ecab3_--