summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-02-09 09:41:36 -0600
committerCraig Jennings <c@cjennings.net>2026-02-09 09:41:36 -0600
commit33584111a5a6146936f9b8c0a89aa907c4fc629c (patch)
tree77bc89084b56d21ab962b212e061d2262962a947
parentec53852489e2bb78e3bd14b390c0f96a0822766b (diff)
fix(font): prevent HarfBuzz SIGSEGV crash on emoji in mu4e headers
Emacs 30.2 + HarfBuzz 12.3.2 segfaults when arabic-shape-gstring is called on emoji characters during mu4e header rendering. Disable Arabic composition ranges, set inhibit-compacting-font-caches, and disable auto-composition in mu4e-headers-mode. Remove duplicate bidi settings from system-defaults.el (already in early-init.el).
-rw-r--r--modules/font-config.el24
-rw-r--r--modules/mail-config.el16
-rw-r--r--modules/system-defaults.el2
3 files changed, 40 insertions, 2 deletions
diff --git a/modules/font-config.el b/modules/font-config.el
index c6422065..c3192b2d 100644
--- a/modules/font-config.el
+++ b/modules/font-config.el
@@ -44,6 +44,30 @@
(require 'host-environment)
+;; ---------------------- HarfBuzz Font Cache Crash Fix -----------------------
+;; Prevents Emacs from compacting font caches during GC. Without this, GC can
+;; free font cache entries that HarfBuzz still references, causing SIGSEGV
+;; crashes during glyph shaping (e.g., rendering emoji in mu4e headers).
+;; See: Emacs bug#12746, coredump traces through hb_shape_full.
+
+(setq inhibit-compacting-font-caches t)
+
+;; --------------- Disable Arabic Shaping (Prevents HarfBuzz SIGSEGV) ---------
+;; Emacs 30.2 + HarfBuzz crashes (SIGSEGV in hb_shape_full) when
+;; arabic-shape-gstring is called on emoji characters in mu4e headers.
+;; Since bidi display is already disabled in early-init.el and Arabic text
+;; shaping is not needed, remove it from the composition function table.
+;; This prevents HarfBuzz from ever using the Arabic shaper. Programming
+;; ligatures and emoji rendering use different shapers and are unaffected.
+
+(with-eval-after-load 'misc-lang
+ (dolist (range '((#x0600 . #x06FF) ;; Arabic
+ (#x0750 . #x077F) ;; Arabic Supplement
+ (#x08A0 . #x08FF) ;; Arabic Extended-A
+ (#xFB50 . #xFDFF) ;; Arabic Presentation Forms-A
+ (#xFE70 . #xFEFF))) ;; Arabic Presentation Forms-B
+ (set-char-table-range composition-function-table range nil)))
+
;; ----------------------- Font Family And Size Selection ----------------------
;; preset your fixed and variable fonts, then apply them to text as a set
diff --git a/modules/mail-config.el b/modules/mail-config.el
index 28423f52..93989f97 100644
--- a/modules/mail-config.el
+++ b/modules/mail-config.el
@@ -16,10 +16,26 @@
;; - followed by , (comma) next to each file you want to save,
;; - then RET (vertico-exit), to save selected attachments.
;;
+;; Crash Fix:
+;; auto-composition-mode is disabled in mu4e-headers-mode to prevent a
+;; HarfBuzz SIGSEGV crash. Email subjects containing emoji trigger glyph
+;; shaping via arabic-shape-gstring → hb_shape_full, which segfaults.
+;; Disabling composition in headers is safe (no ligatures needed there).
+;;
;;; Code:
(require 'user-constants)
+;; -------------------- HarfBuzz Crash Fix: Disable Composition ---------------
+;; Disable auto-composition in mu4e headers to prevent SIGSEGV from HarfBuzz
+;; when shaping emoji characters in email subjects. See Commentary above.
+
+(defun cj/disable-auto-composition ()
+ "Disable `auto-composition-mode' in the current buffer."
+ (auto-composition-mode -1))
+
+(add-hook 'mu4e-headers-mode-hook #'cj/disable-auto-composition)
+
;; ------------------------------ Mark All Headers -----------------------------
;; convenience function to mark all headers for an action
diff --git a/modules/system-defaults.el b/modules/system-defaults.el
index d9441f83..6541fe0f 100644
--- a/modules/system-defaults.el
+++ b/modules/system-defaults.el
@@ -104,8 +104,6 @@ Used to disable functionality with defalias \='somefunc \='cj/disabled)."
(global-auto-revert-mode) ;; update the buffer when the associated file has changed
(setq global-auto-revert-non-file-buffers t) ;; do so for all buffer types (e.g., ibuffer)
-(setq bidi-display-reordering nil) ;; don't reorder bidirectional text for display
-(setq bidi-paragraph-direction t) ;; forces directionality of text for performance.
;; -------------------------------- Emacs Server -------------------------------
;; Start server so emacsclient can connect (needed for pinentry-emacs in terminal)