Subject: Re: bug#11964: describe-char causes a fatal error (abort trap: 6) in non-windowed mode

From: Eli Zaretskii <[email-masked]>
Date: Sun, 25 Nov 2012 17:56:06 +0200

> From: Jan Djärv <[email-masked]>
> Date: Sun, 25 Nov 2012 13:18:28 +0100
> Cc: Eli Zaretskii <[email-masked]>,
>  [email-masked],
>  [email-masked]
> 
> Actually it is not quite fixed, and not NS-specific either.
> On a X11-emacs, do this (tried with Gtk2, 3 and Lucid, no difference):
> 
> % emacs -Q --daemon
> % emacsclient -c &
> % emacsclient -c -t
> 
> In the second, non-GUI frame do (from this bug):
> u C-x 8 <RET> 0303 <RET> C-b C-u C-x =
> 
> The emacs daemon crashes, the same way as the original bug does.
> This is because the emacsclient -c creates fontsets, and emacsclient -c -t tries to use them.
> 
> So this is a more generic problem.  The fix I made was to initialize fontsets in ns-win.el the same way x-win.el does, but this just hides the problem for the daemon case.

It is wrong to call internal-char-font on a non-GUI frame; for
starters, that function might not be compiled in, e.g. if Emacs was
configured --without-x.  All the other callers of that function are
careful not to do that.  Does the patch below fix the problem?

I also think internal-char-font should not blindly call the font
driver without checking that it isn't NULL first.

=== modified file 'lisp/descr-text.el'
--- lisp/descr-text.el	2012-08-20 11:12:16 +0000
+++ lisp/descr-text.el	2012-11-25 15:46:44 +0000
@@ -354,7 +354,8 @@ This function is semi-obsolete.  Use `ge
 ;; Return a string of CH with composition for padding on both sides.
 ;; It is displayed without overlapping with the left/right columns.
 (defsubst describe-char-padded-string (ch)
-  (if (internal-char-font nil ch)
+  (if (and (display-multi-font-p)
+	   (internal-char-font nil ch))
       (compose-string (string ch) 0 1 (format "\t%c\t" ch))
     (string ch)))