Repository navigation
fix: initialize the system FontConfig before GTK starts on Linux - #53314
Merged
Merged
Conversation
MarshallOfSound
force-pushed
the
fix/linux-fontconfig-preinit
branch
from
August 30, 2026 08:06
1e4f97b to
283b682
Compare
Pango >= 1.52 spawns a thread that calls FcInit() as soon as GTK creates its font map. 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, which later surfaces as a PartitionAlloc freelist corruption check (SIGTRAP) or a NULL dereference inside expat. Initialize the system FontConfig library 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 are no-ops. The symbol is resolved with dlsym because the executable also contains Chromium's bundled FontConfig with hidden visibility. If the app's main script changed the FontConfig environment variables, the configuration is reloaded so GTK sees them.
MarshallOfSound
force-pushed
the
fix/linux-fontconfig-preinit
branch
from
August 30, 2026 08:30
283b682 to
ca56ef3
Compare
deepak1556
approved these changes
Aug 31, 2026
ckerr
approved these changes
Aug 31, 2026
ckerr
left a comment
Member
There was a problem hiding this comment.
Nice find, thanks for tracking this down 👍
MarshallOfSound
enabled auto-merge (squash)
August 31, 2026 15:49
MarshallOfSound
disabled auto-merge
August 31, 2026 17:47
|
Release Notes Persisted
|
This was referenced Aug 31, 2026
Contributor
|
I have automatically backported this PR to "45-x-y", please check out #53338 |
Contributor
|
I have automatically backported this PR to "43-x-y", please check out #53339 |
Contributor
|
I have automatically backported this PR to "44-x-y", please check out #53340 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Fixes #53200
[pango] fontconfigthread that callsFcInit()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, [Bug]: Electron 44.0.0 Linux SIGTRAP: PartitionAlloc freelist corruption detected during Fontconfig startup #53200) or a NULL dereference inside expat (Smoke test Electron crash (SIGSEGV) on relaunch — fontconfig/expat font init in browser process microsoft/vscode#322185). Upstream: pango#784, pango#872.FcInit()calls return immediately. Nothing else touches fontconfig or callssetenvduring that window. Resolved viadlsymbecause the binary also contains Chromium's bundled fontconfig with hidden visibility, which is a separate copy with separate state (that is also whygfx::GetGlobalFontConfig()ingtk_ui.ccdoes not prevent this).FONTCONFIG_FILE,FONTCONFIG_PATHorFONTCONFIG_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):
FcInit()Checklist
Release Notes
Notes: Fixed an intermittent crash at startup on Linux caused by a race between Pango and the main thread initializing fontconfig.