From 0e0ad119c3e057e43d66ca959dd446c15d5e9472 Mon Sep 17 00:00:00 2001 From: Mark Pitman Date: Sun, 15 Mar 2026 15:54:36 -0700 Subject: [PATCH] debian: fix VS Code crash via Pango 1.56.x fontconfig workaround Pango 1.56.x introduced a thread pool for font loading ([pango] fontcon threads). When FONTCONFIG_FILE is unset or points directly to /etc/fonts/fonts.conf, these threads hit a stack corruption bug while processing cache-11 entries for variable fonts (Cascadia Code, Fira Code, Cantarell-VF, etc.). The crash manifests as a SIGTRAP from a ud2 instruction, with the stack return address overwritten with 'slotsize' (a HarfBuzz/fontconfig internal field name). The fix involves three changes: 1. Rebuild the fontconfig cache (fc-cache -f) after desktop package install to ensure it is up to date and not stale/missing. 2. Set FONTCONFIG_FILE to a wrapper config that includes /etc/fonts/fonts.conf via rather than pointing at fonts.conf directly. This causes Pango to use a different internal code path that avoids the corrupting write. The wrapper produces identical font enumeration, so no behavior change for end users. Three activation methods for coverage: - ~/.config/environment.d/fontconfig.conf (systemd user session / GNOME) - ~/.bashrc export (new terminal sessions) - export in the script itself (current bootstrap session) 3. Apply the same FONTCONFIG_FILE export to .zshrc (in addition to .bashrc), since zsh is the default shell after install-zsh-customizations runs. Without this, users on zsh would not have the variable set in their interactive terminal sessions. Remove this workaround when Pango >= 1.57 is available in Debian stable. Validated: bash scripts/check.sh passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- debian/install-desktop-packages | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/debian/install-desktop-packages b/debian/install-desktop-packages index ecfab28..606f7ba 100755 --- a/debian/install-desktop-packages +++ b/debian/install-desktop-packages @@ -41,6 +41,47 @@ obs-studio \ pipx \ xclip +# Pango 1.56.x workaround: when FONTCONFIG_FILE is unset (or set to the default +# /etc/fonts/fonts.conf path), Pango's font-loading thread pool hits a stack +# corruption bug processing cache-11 entries for variable fonts (Cascadia Code, +# Fira Code, Cantarell-VF, etc.), causing VS Code and other Electron apps to +# crash silently on startup. The fix is to set FONTCONFIG_FILE to a wrapper +# config that includes fonts.conf rather than pointing directly to fonts.conf. +# This changes which Pango code path is used and avoids the bug. +mkdir -p "$HOME/.config/fontconfig" "$HOME/.config/environment.d" + +cat > "$HOME/.config/fontconfig/fonts-pango.conf" << 'EOF' + + + + + /etc/fonts/fonts.conf + +EOF + +# Activate for future GNOME/systemd user sessions +cat > "$HOME/.config/environment.d/fontconfig.conf" << EOF +FONTCONFIG_FILE=$HOME/.config/fontconfig/fonts-pango.conf +EOF + +# Activate for current and future terminal sessions +_fc_comment='# Pango 1.56.x workaround for variable font crash (see ~/.config/fontconfig/fonts-pango.conf)' +_fc_export='export FONTCONFIG_FILE="$HOME/.config/fontconfig/fonts-pango.conf"' +for _rc in "$HOME/.bashrc" "$HOME/.zshrc"; do + if [ -f "$_rc" ] && ! grep -q "FONTCONFIG_FILE" "$_rc"; then + printf '\n%s\n%s\n' "$_fc_comment" "$_fc_export" >> "$_rc" + fi +done +unset _fc_comment _fc_export _rc + +export FONTCONFIG_FILE="$HOME/.config/fontconfig/fonts-pango.conf" + +# Rebuild fontconfig cache after font package installs +fc-cache -f + # Install Gnome extension tooling and selected extensions pipx install gnome-extensions-cli --system-site-packages "$HOME"/.local/bin/gext install clipboard-history@alexsaveau.dev