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
(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"))
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
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.