Subject: Re: bug#75725: SIGSEGV in emacs 30.0.93

From: Florian Franzmann <[email-masked]>
Date: Tue, 21 Jan 2025 18:20:05 +0100

On Di 2025-01-21 16:18:33 +0200, Eli Zaretskii wrote:
> > Date: Tue, 21 Jan 2025 14:13:38 +0100
> > From: Florian Franzmann <[email-masked]>
> > Cc: [email-masked]
> > 
> > On Di 2025-01-21 14:31:00 +0200, Eli Zaretskii wrote:
> > > > Date: Tue, 21 Jan 2025 09:15:30 +0100
> > > > From: Florian Franzmann <[email-masked]>
> > > > 
> > > > I'm experiencing a segmentation violation in emacs 30.0.93 when linked against GTK.
> > > > The crash does not happen in the TUI version of emacs (which, obviously, is not
> > > > linked against GTK).
> > > > 
> > > > Backtrace:
> > > > 
> > > > #0  normal_char_ascent_descent (font=0x0, c=c@entry=-1, ascent=ascent@entry=0x7fffffff2ad0, descent=descent@entry=0x7fffffff2ad4)
> > > >     at xdisp.c:30407
> > > > #1  0x000000000043b18b in normal_char_height (font=<optimized out>, c=c@entry=-1) at xdisp.c:30443
> > > > #2  0x0000000000455cdf in handle_single_display_spec (it=it@entry=0x7fffffff3150, spec=<optimized out>, spec@entry=0x28266e3,
> > > >     object=<optimized out>, object@entry=0x28dc604, overlay=overlay@entry=0x0, position=position@entry=0x7fffffff32b8,
> > > >     bufpos=bufpos@entry=0, display_replaced=0, frame_window_p=true, enable_eval_p=true) at xdisp.c:6114
> > > > #3  0x00000000004567de in handle_display_spec (it=it@entry=0x7fffffff3150, spec=<optimized out>, spec@entry=0x28266e3,
> > > >     object=object@entry=0x28dc604, overlay=0x0, position=position@entry=0x7fffffff32b8, bufpos=bufpos@entry=0, frame_window_p=true)
> > > >     at xdisp.c:5862
> > > 
> > > Thanks, I installed a trivial fix.  You may not like the results, but
> > > at least Emacs should not crash.
> > Thanks, that fixed the crash.
> 
> Thanks for testing.  Does the resulting display look reasonable (it's
> somewhere on your mode line)?
> 
> > However, I think it would make sense to output some kind of useful
> > information somewhere to help with debugging such issues. Right now
> > it's just a silent error.
> 
> I don't know what to say in the message, sorry.  Saying "font is NULL"
> will not be helpful for most users, I'm afraid.
> 
> Also, Emacs has similar protection against a face's font being NULL in
> quite a few places.  I didn't invent any new technique.
> 
> I could try help you understand what causes this, if you can show me
> your font-related customizations, in particular for what is on the
> mode line.
Here is what I have in my config regarding fonts:

(setq doom-font (font-spec :family "MartianMono Nerd Font" :size 8.000000)
      doom-big-font (font-spec :family "MartianMono Nerd Font" :size 14.000000)
      doom-variable-pitch-font (font-spec :family "Noto Sans" :size 12.000000)
      doom-symbol-font (font-spec :family "MartianMono Nerd Font")
      doom-serif-font (font-spec :family "Noto Serif" :size 12.000000)
      my-org-font "Crimson Pro")
;; ...
(defun my-refine-org-theme ()
  "Custom refinements of the org-mode appearance."
  (when window-system
    (let* (
           (custom--inhibit-theme-enable nil)
           (variable-tuple     `(:font ,my-org-font))
           (base-font-color     (face-foreground 'default nil 'default))
           (headline           `(:inherit default :foreground ,base-font-color))
           )

      (custom-theme-set-faces
       'user
       '(org-block ((t (:inherit fixed-pitch))))
       '(org-code ((t (:inherit (shadow fixed-pitch)))))
       '(org-document-info ((t (:foreground "dark orange"))))
       '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
       '(org-indent ((t (:inherit (org-hide fixed-pitch)))))
       '(org-link ((t (:foreground "royal blue" :underline t))))
       '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
       '(org-property-value ((t (:inherit fixed-pitch))) t)
       '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
       '(org-table ((t (:inherit fixed-pitch :foreground "#83a598"))))
       '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 1.0))))
       '(org-verbatim ((t (:inherit (shadow fixed-pitch)))))
       `(org-document-title ((t (,@headline ,@variable-tuple :height 2.0736 :underline nil :bold nil))))
       `(org-level-1 ((t (,@headline ,@variable-tuple :height 2.0736))))
       `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.728))))
       `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.44))))
       `(org-level-4 ((t (,@headline ,@variable-tuple :height 1.2))))
       `(org-level-5 ((t (,@headline ,@variable-tuple :height 1.0))))
       `(org-level-6 ((t (,@headline ,@variable-tuple :height 1.0))))
       `(org-level-7 ((t (,@headline ,@variable-tuple :height 1.0))))
       `(org-level-8 ((t (,@headline ,@variable-tuple :height 1.0))))
       `(org-default ((t (,@headline ,@variable-tuple :height 1.0))))
       )
      ))
  )

and then somewhere
  (add-hook 'after-enable-theme-hook 'my-refine-org-theme)
  (add-hook 'org-mode-hook 'my-refine-org-theme)

Maybe using MartianMono as doom-symbol-font is problematic?

--