Subject: bug#18573: 24.3.93; set-face-attribute crashes Emacs when started with -nw

From: Jan Djärv <[email-masked]>
Date: Sun, 28 Sep 2014 10:44:15 +0200

Hello.

27 sep 2014 kl. 18:13 skrev [email-masked]:

> 
> When launched via terminal (cli), Emacs crashes by just having this single line in init.el:
> 
> (set-face-attribute 'default nil :font  "Menlo-16")
> 
> Emacs does /not/ crash when launched from the Finder (same init.el)
> 

This seems to be a generic error in xfaces.c.  It tries to load a font without checking the type
of frame.  The type is tty, but it tries to load a font anyway, and eventually ends up in (font.c) font_pixel_size, which does:

#define FRAME_RES_Y(f)						\
  (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)

Now, FRAME_DISPLAY_INFO for a NS compiled Emacs is

#define FRAME_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)

but the frame is not an NS frame, it is a tty frame, so bad things happen.
It is the same for X, but there it just happens to return a nonsense value, so the code continues without crashing, and eventually discovers that there are no font dirvers and the load font fails.

The code is in xfaces.c, Finternal_set_lisp_face_attribute, around line 3120 where it calls
font_load_for_lface.

The code in question is not called if compiled for a tty (#ifdef:ed out), but it is called when the frame is a tty frame on a non-tty compiled Emacs.

I think these cases should be the same, i.e. font_load_for_lface not called for tty frames.

	Jan D.

> I am using GNU Emacs 24.3.93.1 (x86_64-apple-darwin13.3.0, NS apple-appkit-1265.21) of 2014-08-15 on builder10-9.porkrind.org on OS X 10.9.4
> 
> 
> Sam Ask
> 
> 
> 
> 
> 
> In GNU Emacs 24.3.93.1 (x86_64-apple-darwin13.3.0, NS apple-appkit-1265.21)
> of 2014-08-15 on builder10-9.porkrind.org
> Windowing system distributor `Apple', version 10.3.1265
> Configured using:
> `configure --with-ns'
> 
> Important settings:
>  locale-coding-system: utf-8-unix
> 
> Major mode: Fundamental
> 
> Minor modes in effect:
>  tooltip-mode: t
>  electric-indent-mode: t
>  mouse-wheel-mode: t
>  tool-bar-mode: t
>  menu-bar-mode: t
>  file-name-shadow-mode: t
>  global-font-lock-mode: t
>  blink-cursor-mode: t
>  auto-composition-mode: t
>  auto-encryption-mode: t
>  auto-compression-mode: t
>  buffer-read-only: t
>  line-number-mode: t
>  transient-mark-mode: t
> 
> Recent input:
> M-x e m a c s b u <tab> <backspace> <backspace> - b
> u g - r e p o r t <return> <backspace> <backspace>
> <backspace> <backspace> <backspace> <backspace> <backspace>
> <backspace> <backspace> <backspace> <backspace> <backspace>
> <backspace> <backspace> <backspace> <backspace> r e
> p o r t <tab> <return>
> 
> Recent messages:
> Loading /Users/sam/.emacs.d/init.el (source)...done
> For information about GNU Emacs and the GNU system, type C-h C-a.
> delete-backward-char: Text is read-only
> 
> Load-path shadows:
> None found.
> 
> Features:
> (shadow sort gnus-util mail-extr emacsbug message cl-macs format-spec
> rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse
> rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
> ietf-drums mm-util help-fns mail-prsvr mail-utils cl gv cl-loaddefs
> cl-lib time-date tooltip electric uniquify ediff-hook vc-hooks
> lisp-float-type mwheel ns-win tool-bar dnd fontset image regexp-opt
> fringe tabulated-list newcomment lisp-mode prog-mode register page
> menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
> syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
> vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
> romanian slovak czech european ethiopic indian cyrillic chinese
> case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
> loaddefs button faces cus-face macroexp files text-properties overlay
> sha1 md5 base64 format env code-pages mule custom widget
> hashtable-print-readable backquote make-network-process cocoa ns
> multi-tty emacs)
> 
> Memory information:
> ((conses 16 75113 4885)
> (symbols 48 17760 0)
> (miscs 40 78 113)
> (strings 32 10523 3551)
> (string-bytes 1 303408)
> (vectors 16 9703)
> (vector-slots 8 378700 13839)
> (floats 8 53 97)
> (intervals 56 214 0)
> (buffers 960 12))
> 
>