all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: emacs-devel@gnu.org
Subject: switching font backends in .emacs.desktop causes crash
Date: Fri, 08 Feb 2019 13:09:22 +0100	[thread overview]
Message-ID: <m21s4ipjm5.fsf@gmail.com> (raw)


Playing around with the various X font backend build options resulted
in me having a .emacs.desktop like so:

;; -*- mode: emacs-lisp; lexical-binding:t; coding: utf-8-emacs; -*-
;; --------------------------------------------------------------------------
;; Desktop File for Emacs
;; --------------------------------------------------------------------------
;; Created Fri Feb  8 09:02:42 2019
;; Desktop file format version 208
;; Emacs version 27.0.50

;; Global section:
(setq desktop-saved-frameset [frameset 1 (23645 14242 497425
32000) (desktop . "208") "rpluim@rpluim-ubuntu" nil
nil ((((minibuffer . t) (undecorated) (override-redirect) (font-backend x))))])

and .emacs:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(desktop-save-mode t)
)

I rebuilt with the XFT and X backends (default configuration), and
got:

    $ ./emacs
    Fatal error 11: Segmentation fault
    Backtrace:
    ./emacs(+0x1338ce)[0x5568bfc208ce]
    ./emacs(+0x119e4a)[0x5568bfc06e4a]
    ./emacs(+0x131c9e)[0x5568bfc1ec9e]
    ./emacs(+0x131f48)[0x5568bfc1ef48]
    ./emacs(+0x131fcc)[0x5568bfc1efcc]
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7ff5f243f890]
    /usr/lib/x86_64-linux-gnu/libXft.so.2(XftCharIndex+0xd)[0x7ff5f5c5568d]

Poking around with gdb, I see that the xftfont field of xftfont_info
is NULL, so I set a watchpoint:

    $ gdb emacs
    (gdb) l xftfont.c:320
    315	  ASET (font_object, FONT_FILE_INDEX, filename);
    316	  font = XFONT_OBJECT (font_object);
    317	  font->pixel_size = size;
    318	  font->driver = &xftfont_driver;
    319	  font->encoding_charset = font->repertory_charset = -1;
    320	
    321	  xftfont_info = (struct font_info *) font;
    322	  xftfont_info->display = display;
    323	  xftfont_info->xftfont = xftfont;
    324	  xftfont_info->x_display_id = FRAME_DISPLAY_INFO (f)->x_id;
    (gdb) b 324
    Breakpoint 3 at 0x204b47: file xftfont.c, line 324.
    (gdb) r
    Starting program: /home/rpluim/repos/emacs-real-master/src/emacs 
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    [New Thread 0x7fffe4a29700 (LWP 12037)]
    [New Thread 0x7fffdf41b700 (LWP 12039)]
    [New Thread 0x7fffdea0d700 (LWP 12040)]

    Thread 1 "emacs" hit Breakpoint 3, xftfont_open (f=0x55555646b2a0, 
        entity=XIL(0x5555560a6975), pixel_size=27) at xftfont.c:324
    324	  xftfont_info->x_display_id = FRAME_DISPLAY_INFO (f)->x_id;
    (gdb) watch -l xftfont_info->xftfont
    Hardware watchpoint 4: -location xftfont_info->xftfont
    (gdb) d 3
    (gdb) c
    Continuing.

    Thread 1 "emacs" hit Hardware watchpoint 4: -location xftfont_info->xftfont

    Old value = (XftFont *) 0x5555564738e0
    New value = (XftFont *) 0x0
    xftfont_close (font=0x5555560a6a60) at xftfont.c:464
    464	}
    (gdb) bt
    #0  0x000055555575914e in xftfont_close (font=0x5555560a6a60) at xftfont.c:464
    #1  0x00005555556fd454 in font_clear_cache (cache=XIL(0x555555e4c8b3), driver=driver@entry=0x5555559e11e0 <xftfont_driver>, f=0x55555646b2a0) at font.c:2643
    #2  0x0000555555702e35 in font_finish_cache (driver=0x5555559e11e0 <xftfont_driver>, f=0x55555646b2a0) at font.c:2588
    #3  0x0000555555702e35 in font_update_drivers (f=f@entry=0x55555646b2a0, new_drivers=new_drivers@entry=XIL(0x555558155c13)) at font.c:3545
    #4  0x00005555555a2a0f in x_set_font_backend (f=0x55555646b2a0, new_value=<optimized out>, old_value=XIL(0x555555e4c7b3)) at frame.c:4400
    #5  0x00005555555a1408 in x_set_frame_parameters (f=f@entry=0x55555646b2a0, alist=alist@entry=XIL(0x55555815b603)) at frame.c:3933
    #6  0x00005555555a1e9c in Fmodify_frame_parameters (frame=<optimized out>, alist=XIL(0x55555815b603)) at frame.c:3197
    
    Lisp Backtrace:
    "modify-frame-parameters" (0xffffb898)
    "frameset--restore-frame" (0xffffbc90)
    "frameset-restore" (0xffffc1f0)
    "desktop-restore-frameset" (0xffffc458)
    "desktop-read" (0xffffc7e0)
    0x563cec70 PVEC_COMPILED
    "run-hooks" (0xffffcae0)
    "command-line" (0xffffd388)
    "normal-top-level" (0xffffd700)

So it looks like we're closing the xft font backend, because of the
(font-backend x) in the desktop file, and flushing the font cache. Looking at where it crashes exactly:

    (gdb) c
    Continuing.

    Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
    0x00007ffff446468d in XftCharIndex () from /usr/lib/x86_64-linux-gnu/libXft.so.2
    (gdb) bt
    #0  0x00007ffff446468d in XftCharIndex () at /usr/lib/x86_64-linux-gnu/libXft.so.2
    #1  0x0000555555758689 in xftfont_encode_char (font=<optimized out>, c=<optimized out>)
    at xftfont.c:532
    #2  0x00005555555d60a9 in get_char_glyph_code (char2b=<synthetic pointer>, font=0x555557b49470, c=<optimized out>) at xdisp.c:25915
    #3  0x00005555555d60a9 in x_produce_glyphs (it=0x7fffffff9b00) at xdisp.c:28294

Here we're using xftfont_encode_char, even though we've just closed
the XFT font backend and should be using the X one for the minibuffer?
Is the 'it' there caching XFT information?

I have no idea how to fix this. I can reproduce at will if more gdb
info is needed (BTW, emacs-26 has the same issue).

    Lisp Backtrace:
    "message" (0xffffc458)
    "desktop-read" (0xffffc7e0)
    0x563cec70 PVEC_COMPILED
    "run-hooks" (0xffffcae0)
    "command-line" (0xffffd388)
    "normal-top-level" (0xffffd700)



             reply	other threads:[~2019-02-08 12:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-08 12:09 Robert Pluim [this message]
2019-02-08 14:20 ` switching font backends in .emacs.desktop causes crash martin rudalics
2019-02-08 14:49   ` Robert Pluim
2019-02-08 15:54     ` martin rudalics
2019-02-08 16:14       ` Robert Pluim
2019-02-08 15:58     ` Eli Zaretskii
2019-02-08 16:16       ` Robert Pluim
2019-02-08 21:19         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m21s4ipjm5.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.