MarshallOfSound

#53314: fix: initialize the system FontConfig before GTK starts on Linux

Merged
Created: Aug 30, 2026, 2:49:19 AM
Merged: Aug 31, 2026, 12:47:11 PM
4 comments
Target: main

Description of Change

Fixes #53200

  • Pango 1.52+ spawns a [pango] fontconfig thread that calls FcInit() as soon as GTK creates its font map, and that races the main thread's own first fontconfig call during toolkit initialization. Both parse the configuration at once and corrupt fontconfig's global state; it later surfaces as a PartitionAlloc freelist check (SIGTRAP, #53200) or a NULL dereference inside expat (microsoft/vscode#322185). Upstream: pango#784, pango#872.
  • Initialize the system fontconfig once on a helper thread that runs while the Node.js environment is created and is joined before any app code runs, so both later FcInit() calls return immediately. Nothing else touches fontconfig or calls setenv during that window. Resolved via dlsym because the binary also contains Chromium's bundled fontconfig with hidden visibility, which is a separate copy with separate state (that is also why gfx::GetGlobalFontConfig() in gtk_ui.cc does not prevent this).
  • If the app's main script changed FONTCONFIG_FILE, FONTCONFIG_PATH or FONTCONFIG_SYSROOT, reload the configuration after the join so GTK still sees what the app asked for.

Main-thread cost, measured with a temporary log around the join (Testing build, Xvfb, warm cache, 8 launches):

median
helper thread FcInit() 3.8 ms (off main thread)
main thread wait at the join 27 µs
reload when the app changed the env 3.6 ms (only in that case)

Checklist

Release Notes

Notes: Fixed an intermittent crash at startup on Linux caused by a race between Pango and the main thread initializing fontconfig.

Backports

43-x-y
Merged
PR Number
#53339
Merged At
Aug 31, 2026, 2:08:25 PM
Released In
Not yet
Release Date
Not yet
44-x-y
Merged
PR Number
#53340
Merged At
Aug 31, 2026, 2:09:23 PM
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#53338
Merged At
Aug 31, 2026, 2:39:06 PM
Released In
v45.0.0-alpha.3
Release Date
Aug 31, 2026, 3:00:16 PM

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron