0

I am reproducibly experiencing segmentation faults on Emacs 26.3 under Debian Buster when creating a new frame, which seems to be related to setting fonts for new frames.

In order to illustrate I have the following minimal init.el file:

(defun ah/setup-gui-frame (frame)
    (let* ((variable-pitch-serif-tuple
        (cond
         ((x-list-fonts "Garamond") '(:font "Garamond"))
         (nil (warn "Cannot find a Serif Font."))))
       (headline `(:inherit default :weight bold))
       )
      (custom-theme-set-faces
       'user
       `(variable-pitch            ((t (,@variable-pitch-serif-tuple :height 160))))
       )
      )
  )

(add-hook 'after-make-frame-functions
    (lambda (frame)
        (when (display-graphic-p frame)
      (ah/setup-gui-frame frame))))

(add-hook 'org-mode-hook 'variable-pitch-mode)
(add-to-list 'default-frame-alist '(font-backend . "xft"))

The ah/setup-gui-frame function is in reality larger since I want to use the same init file on different machines where different sets of fonts might be installed, and I'm also setting some org-mode faces in there -- but this minimal example already shows the bad behavior.

Now, when I start Emacs and open an org-mode file, the buffer contents are not displayed in Garamond, but in the system's default sans-serif font.

When I now open a new frame with C-x 5 2, the org-mode file in both the new and the old frame are displayed in Garamond.

I can now open new frames with C-x 5 2, but when I open the fourth additional (in total) frame, Emacs quits with a segmentation fault.

When instead of setting the variable-pitch-serif-tuple and instead directly set the font's name, like this

   `(variable-pitch            ((t (:font "Garamond" :height 160))))

the same happens (except that the segmentation fault occurs one frame "earlier").

The same happens when running Emacs as a deamon and connecting with emacsclient. (That's why this is so annoying: I'm using emacsclient a lot, and therefore I can easily have more than 5 frames open at any one time).

How do I properly set font faces for GUI frames when using emacs --daemon?

UPDATE: As recommended in the comments, I did submit a bug report to the Emacs bug tracker, and the problem was since solved. The fix is already merged in the master branch and will be in the next release.

  • 2
    M-x report-emacs-bug. Emacs should not crash (although there a no plans for further releases of emacs-26, so perhaps you could see if emacs-27 behaves the same). – rpluim Oct 4 at 12:48
  • just FYI I was having that problem, a couple of months ago, when emacs tried to render some emojis which system was doing using noto color emoji. Uninstalling the font was que quick and dirty solution to me. Far better to have an square filled with numbers instead an emoji than a segfault. I'd start checkig if the trouble has something to do with this. – Muihlinn Oct 4 at 13:23
  • 1
    What @rpluim said. Any crash is an Emacs bug - please report this. – Drew Oct 4 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.