Subject: bug#7587: 23.2; `format-mode-line' makes Emacs crash

From: Eli Zaretskii <[email-masked]>
Date: Fri, 10 Dec 2010 18:02:21 +0200

> From: Michael Heerdegen <[email-masked]>
> Date: Tue, 07 Dec 2010 22:01:25 +0100
> Cc: 
> 
> if I evaluate the following sexp in a fresh emacs -Q (e.g. with
> `eval-expression'):
> 
> (progn
>   (face-remap-add-relative 'mode-line :height 1.0)
>   (format-mode-line mode-line-format t))
> 
> Emacs instantly crashes.

This happens because, for some reason I don't understand, when
face-remapping-alist is non-nil, lookup_basic_face insists on getting
only one of the basic faces, and otherwise aborts:

  if (NILP (Vface_remapping_alist))
    return face_id;		/* Nothing to do.  */

  switch (face_id)
    {
    case DEFAULT_FACE_ID:		name = Qdefault;		break;
    case MODE_LINE_FACE_ID:		name = Qmode_line;		break;
    case MODE_LINE_INACTIVE_FACE_ID:	name = Qmode_line_inactive;	break;
    case HEADER_LINE_FACE_ID:		name = Qheader_line;		break;
    case TOOL_BAR_FACE_ID:		name = Qtool_bar;		break;
    case FRINGE_FACE_ID:		name = Qfringe;			break;
    case SCROLL_BAR_FACE_ID:		name = Qscroll_bar;		break;
    case BORDER_FACE_ID:		name = Qborder;			break;
    case CURSOR_FACE_ID:		name = Qcursor;			break;
    case MOUSE_FACE_ID:			name = Qmouse;			break;
    case MENU_FACE_ID:			name = Qmenu;			break;

    default:
      abort ();	    /* the caller is supposed to pass us a basic face id */
    }

This is inconsistent, because if face-remapping-alist _is_ nil, the
function returns face_id unaltered, no matter if it is or isn't a
basic face.

Any objections to the following patch?  On the release branch as well?

=== modified file 'src/xfaces.c'
--- src/xfaces.c	2010-08-06 10:12:41 +0000
+++ src/xfaces.c	2010-12-10 15:58:25 +0000
@@ -4673,9 +4673,6 @@ lookup_basic_face (struct frame *f, int 
     case CURSOR_FACE_ID:		name = Qcursor;			break;
     case MOUSE_FACE_ID:			name = Qmouse;			break;
     case MENU_FACE_ID:			name = Qmenu;			break;
-
-    default:
-      abort ();	    /* the caller is supposed to pass us a basic face id */
     }
 
   /* Do a quick scan through Vface_remapping_alist, and return immediately