Skip to content

ci: install CVE-fixed libexpat to fix fontconfig SIGSEGV in Electron smoke tests - #323001

Closed
Alexandru Dima (alexdima) wants to merge 2 commits into
mainfrom
fix-install-libexpat-fontconfig-crash
Closed

Alexandru Dima (alexdima) wants to merge 2 commits into
mainfrom
fix-install-libexpat-fontconfig-crash

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

Supersedes the from-source build idea — installs a prebuilt official Ubuntu .deb, fetched from the Azure Ubuntu mirror the runner already uses. Also includes the revert of #322909 (so it works whether or not the standalone revert #322994 lands first).

Root cause (confirmed)

Intermittent Linux Electron-Smoke failures are a SIGSEGV in libexpat during fontconfig parsing at Electron startup, before any window appears. Frame-pointer (RBP) backtrace from a CI crash dump (run 28188049700):

#0  libc.so.6        (NULL deref, fault addr 0x0)
#1-3 libexpat.so.1   (XML_ParseBuffer ...)
#4-9 libfontconfig.so.1  (FcInit / config parse)
#10 libpangoft2-1.0.so.0
#11 libglib-2.0.so.0  (worker thread)
#12 libc.so.6        (thread start)

Ubuntu 24.04 (noble) ships libexpat1 2.6.1; the relevant parser NULL-deref fixes are only in expat ≥ 2.7.5, which noble hasn't packaged. Earlier fontconfig-config tweaks only perturbed timing (removing the <!DOCTYPE> in #322909 actually doubled the crash rate, ~8% → ~19% — reverted here).

Fix

Install the official prebuilt libexpat1 2.8.1 .deb onto the noble runner:

  • Fetched from the Azure Ubuntu mirror the runner already uses (azure.archive.ubuntu.com, in-datacenter), falling back to the canonical Ubuntu archive and then Launchpad's permanent store. All three serve the byte-identical official build; we pin the sha256.
  • That package Pre-Depends: libc6 (>= 2.38) only, and noble has libc6 2.39, so dpkg -i installs it cleanly with no dependency conflict.
  • It replaces the system libexpat.so.1 (ABI-stable SONAME) for every process, including the Electron browser process where the crash happens — no LD_PRELOAD needed.
  • The step auto-skips once the runner ships libexpat1 >= 2.7.5 (so it self-removes when noble backports the fix).

The minimal fontconfig config (DOCTYPE restored via the revert) is kept as secondary stabilization.

Why not plain apt install libexpat1 / why this source

  • noble's apt pocket only carries 2.6.1; the fix lives in newer releases (questing 2.7.1, resolute 2.7.4, stonking 2.8.1).
  • packages.microsoft.com and dl.google.com (the runner's other apt origins) don't carry libexpat1.
  • The Azure mirror is a full mirror of the Ubuntu archive, so its pool hosts the newer-release deb too — byte-identical to Launchpad (verified). So this is "use the package manager's source", just pulling a build noble's own pocket doesn't carry yet.

Validation

  • Workflow YAML parses; no duplicate steps.
  • Verified the 2.8.1 deb Pre-Depends: libc6 (>= 2.38) (installs on noble's 2.39).
  • Verified the Azure mirror, the Ubuntu archive, and Launchpad all return the deb with the same sha256; simulated the download+verify loop end-to-end.
  • Real proof is CI crash-rate; companion PR smoke: fail fast with actionable error when Electron crashes during launch #322905 (fail-fast launch) surfaces any residual crash quickly instead of as a 120s opaque timeout.

Co-authored-by: Copilot [email protected]

…NULL-deref crash (#322909)"

This reverts commit 70c0a5d.

The change made the Linux Electron-Smoke crash *worse*, not better. Measured
against the PR workflow, the Linux / Electron-Smoke job failure rate rose from
~8% (1/13) before the merge to ~19% (8/43) after it — roughly double.

The original hypothesis (that fontconfig feeds the external DTD to expat as an
external parameter entity and triggers the not-yet-backported NULL-deref CVEs)
was not supported by the evidence. A proper frame-pointer backtrace of an
after-merge crash dump shows the same intermittent
libpangoft2 -> libfontconfig -> libexpat -> libc NULL-deref as before, just
more frequently. The minimal config without the DOCTYPE actually parses *less*
XML than the system config yet crashes more often, which points at a flaky
race/heap issue in the expat 2.6.1 + fontconfig stack that this change
perturbed rather than a deterministic content problem.

Revert to restore the previous, lower crash rate. The durable fix remains
shipping libexpat >= 2.7.5 on the runner (the workaround step already
auto-disables itself when that version is detected); that is being tracked
separately.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Linux CI workflow to mitigate intermittent Electron smoke-test startup crashes on Ubuntu 24.04 by ensuring a CVE-fixed libexpat1 is installed (via a pinned, prebuilt Ubuntu .deb) and by restoring the previous minimal fontconfig config behavior.

Changes:

  • Restore the <!DOCTYPE ...> line in the minimal fontconfig config used by the existing expat/fontconfig workaround.
  • Add a workflow step that conditionally downloads (sha256-pinned) and installs libexpat1 2.8.1 via dpkg when the runner’s version is < 2.7.5.
  • Extend diagnostics output to include the active libexpat1 version.
Show a summary per file
File Description
.github/workflows/pr-linux-test.yml Restores minimal fontconfig DOCTYPE, installs newer pinned libexpat1 on noble runners, and prints expat version in diagnostics to stabilize Electron smoke startup.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment thread .github/workflows/pr-linux-test.yml Resolved
Comment thread .github/workflows/pr-linux-test.yml Resolved
…smoke tests

Ubuntu 24.04 runners ship libexpat1 2.6.1, which intermittently NULL-derefs
while fontconfig parses font-config XML during Electron/Chromium startup. A
frame-pointer backtrace of a CI crash dump shows the fault on a glib worker
thread:

    libpangoft2 -> libfontconfig (FcInit/parse) -> libexpat (XML_ParseBuffer)
    -> libc (NULL deref, signal 11)

before any window appears. The earlier fontconfig-config tweaks (minimal config,
removing <include>/<!DOCTYPE>) only changed timing and did not remove the
runtime XML parse, so the crash persisted; removing the DOCTYPE actually made it
more frequent (reverted in the previous commit).

The fix only exists in expat >= 2.7.5, which noble does not package yet. Install
the official prebuilt libexpat1 2.8.1 .deb, fetched from the Azure Ubuntu mirror
the runner already uses (falling back to the canonical archive and Launchpad,
all byte-identical and sha256-pinned). It Pre-Depends only on libc6 (>= 2.38),
satisfied by noble's 2.39, so `dpkg -i` installs it cleanly and replaces the
system libexpat.so.1 (ABI-stable SONAME) for every process, including Electron.
The step auto-skips once the runner ships libexpat1 >= 2.7.5.

The minimal fontconfig config (with its DOCTYPE restored) is kept as secondary
stabilization. Diagnostics print the active libexpat1 version for verification.

Co-authored-by: Copilot <[email protected]>
@alexdima

Copy link
Copy Markdown
Member Author

Closing: verified ineffective. CI run 28192795744 installed libexpat 2.8.1 correctly (libexpat1 is now: 2.8.1-1) but still crashed. The new crash dump's frame-pointer backtrace shows the expat offsets changed (so 2.8.1 was loaded) yet the libfontconfig + libc frames are identical — the fault is a nondeterministic race in the system fontconfig/pango startup path, not an expat bug. Superseded by the launch-retry fix in #323007. The DOCTYPE regression revert lives in #322994.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants