Skip to content

[Linux] Hide libunwind symbols in libflutter_linux_gtk.so - #196451

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
joellemd:fix-linux-unwind-exports
Nov 20, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:masterfrom
joellemd:fix-linux-unwind-exports

Conversation

@joellemd

@joellemd joellemd commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Because the engine library is loaded before libgcc_s, libstdc++ and libgcc_s bind _Unwind_RaiseException to the engine's copy (see the LD_DEBUG=bindings output in the issue). A plugin that throws and catches its own C++ exception then aborts with terminate called after throwing an instance of .... One real-world case: flutter_secure_storage_linux crashes the app at startup on machines without an unlocked keyring, where it should return a PlatformException.

Changes

  • build/config/compiler/BUILD.gn: add -Wl,--exclude-libs,libunwind.a next to --unwindlib=libunwind, so libunwind stays statically linked but its symbols are local to each shared library.
  • testing/symbols/check_forbidden_native_symbols: add a --forbid-exported-unwind-symbols flag, turned on for Linux. It runs llvm-nm --dynamic --defined-only and fails on any exported symbol from libunwind (_Unwind_*, unw_*, __unw_*, __register_frame*, __deregister_frame*). This covers libflutter_linux_gtk.so, which verify_exported.dart doesn't check on Linux, and libflutter_engine.so.

Testing

  • nm -D --defined-only libflutter_linux_gtk.so | grep -E '_Unwind_|unw_|register_frame' is empty for debug, profile and release builds.
  • With the --exclude-libs flag removed, check_native_symbols fails and lists the leaked symbols.
  • The reproduction plugin from the issue now prints unwind_probe: caught: thrown inside the plugin with a local engine.

Fixes #196402

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant in-code documentation (doc comments with ///).
  • If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added the engine flutter/engine related. See also e: labels. label Nov 12, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request prevents libunwind symbols from leaking into the dynamic symbol table of shared libraries on Linux by adding the -Wl,--exclude-libs,libunwind.a linker flag. It also updates the symbol checker tool to verify that no unwinder symbols are exported when the --forbid-exported-unwind-symbols flag is enabled. Feedback suggests using a regular expression to split the output of llvm-nm on any whitespace sequence rather than a single space to make the parsing more robust.

@joellemd
joellemd force-pushed the fix-linux-unwind-exports branch from cbe9e74 to 77ad0e1 Compare November 12, 2026 15:07
@joellemd joellemd closed this Nov 12, 2026
@joellemd joellemd reopened this Nov 13, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 18befb76608487bd5ee441e0c43d9329ad3231e2, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@joellemd
joellemd force-pushed the fix-linux-unwind-exports branch from 18befb7 to f5124b2 Compare November 13, 2026 05:19
@joellemd
joellemd force-pushed the fix-linux-unwind-exports branch from f5124b2 to 4c781cf Compare November 16, 2026 12:35
@gaaclarke
gaaclarke self-requested a review November 17, 2026 21:38
@gaaclarke gaaclarke added the CICD Run CI/CD label Nov 18, 2026

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm! thanks

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 18, 2026
@gaaclarke gaaclarke added the CICD Run CI/CD label Nov 18, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 18, 2026
@gaaclarke gaaclarke added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Nov 18, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 19, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2026
@auto-submit

auto-submit Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/196451, because - The status or check suite Mac_arm64_verify_binaries has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite Tree_analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dcharkes dcharkes added the CICD Run CI/CD label Nov 20, 2026
@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 20, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 20, 2026
Merged via the queue into flutter:master with commit 203c0c4 Nov 20, 2026
33 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 20, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 21, 2026
flutter/flutter@b34b017...5423f94

2026-11-21 [email protected] Make an Impeller render target from a Vulkan backing store (flutter/flutter#193003)
2026-11-21 [email protected] Persist the vulkan shader cache on teardown (flutter/flutter#197017)
2026-11-21 [email protected] [flutter_tools] Preserve rolling log buffer for Chromium crash diagnostics (flutter/flutter#196037)
2026-11-21 [email protected] Roll Skia from 8845aecd8c53 to 39e0ad394168 (2 revisions) (flutter/flutter#197094)
2026-11-21 [email protected] Adds redirect for listen package in api.flutter.dev (flutter/flutter#197068)
2026-11-21 [email protected] Roll Dart SDK from c6857d58f0ec to fc86f5a42779 (1 revision) (flutter/flutter#197086)
2026-11-20 [email protected] iOS: Discard pending platform view disposals on reset (flutter/flutter#197026)
2026-11-20 [email protected] Tolerate a missing flutter/service_worker handler in the web first-frame notification (flutter/flutter#196329)
2026-11-20 [email protected] Roll Skia from 9aafbb357743 to 8845aecd8c53 (2 revisions) (flutter/flutter#197080)
2026-11-20 [email protected] Prevent crash in tessellator with extreme radii (flutter/flutter#196648)
2026-11-20 [email protected] Windows: in the flutter tool, always close the file handle in _download even when an HTTP request fails so that it is not left open and becomes undeletable (flutter/flutter#197061)
2026-11-20 [email protected] Roll Skia from b61640825c5b to 9aafbb357743 (7 revisions) (flutter/flutter#197066)
2026-11-20 [email protected] Swap dependabot reviewers (flutter/flutter#196995)
2026-11-20 [email protected] [iOS] Hide UIScrollEdgeEffect on FlutterSemanticsScrollView and scroll-to-top UIScrollView on iOS 26+ (flutter/flutter#195356)
2026-11-20 [email protected] [devicelab] Enable Vulkan GPU tracing by default on Android Impeller PerfTests (flutter/flutter#196822)
2026-11-20 [email protected] Roll Dart SDK from 3b5f45d812f8 to c6857d58f0ec (1 revision) (flutter/flutter#197063)
2026-11-20 [email protected] [flutter_tools] Delete flutter.version.json when switching channels (flutter/flutter#196943)
2026-11-20 [email protected] Update desktop TESTOWNERS (flutter/flutter#196930)
2026-11-20 [email protected] [web] Release CanvasKit WebGL contexts and surfaces when a view is removed (flutter/flutter#196816)
2026-11-20 [email protected] [Linux] Hide libunwind symbols in libflutter_linux_gtk.so (flutter/flutter#196451)
2026-11-20 [email protected] Roll Skia from a1edf5c2ea5c to b61640825c5b (1 revision) (flutter/flutter#197058)
2026-11-20 [email protected] [flutter_tools] Update --web-content-hash serving tip to cover assets and canvaskit (flutter/flutter#196908)
2026-11-20 [email protected] Send a semantics update when only the identifier changes (flutter/flutter#196460)
2026-11-20 [email protected] Roll Packages from 81b7c44 to 898818d (11 revisions) (flutter/flutter#197056)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
arsfeld added a commit to getmydia/mydia that referenced this pull request Nov 22, 2026
Flutter 3.50's libflutter_linux_gtk.so exports libunwind's _Unwind_*
symbols (flutter/flutter#196402). The runner listed it ahead of libgcc_s,
so every C++ throw bound to the engine's unwinder, which cannot find
libstdc++ catch handlers. flutter_secure_storage_linux catches its own
LibsecretError when no Secret Service is reachable, and instead the player
aborted at launch:

  terminate called after throwing an instance of 'LibsecretError'

That failed Nix / player-e2e and the Flatpak smoke test, and a Rust panic
in the p2p library would abort the same way. Linking libgcc_s first puts
its unwinder ahead in symbol lookup; launched with no session bus, the
player now logs the PlatformException and falls back to in-memory storage.

The engine fix, flutter/flutter#196451, is on Flutter master but in no 3.50
release; the CMake comment says to drop this once .fvmrc pins one.
chingjun added a commit to chingjun/flutter that referenced this pull request Nov 24, 2026
The branch was rebased onto master (ac8f87e, 56 commits after the
last base, 752015c). The replay changed none of its 631 commits
(their patch ids are the old chain's), and a merge of the same master
into the old head had no conflict in the text. The commits below this
one keep the lock file and the generated files of the old base.

This commit adds what master's 56 commits need. Its tree is the tree
of that merge with the files below.

In it:

- deps.lock.bzl for master's DEPS: the Skia and Dart rolls, and the
  Dart SDK's own dependencies. pub.lock.bzl does not change.
- The converter's output for the two test sources master added:
  impeller/renderer/backend/vulkan/BUILD.bazel
  (pipeline_cache_vk_unittests.cc) and shell/platform/linux/BUILD.bazel
  (fl_socket_accessible_test.cc). The new Dart test files (web_ui, the
  framework) are picked up by globs.
- The port of flutter#196451 ("[Linux] Hide libunwind symbols
  in libflutter_linux_gtk.so") to the two hand-written files that
  mirror the GN it changed:
  - toolchains/cc_toolchain_config.bzl: a Linux link passes
    -Wl,--exclude-libs,libunwind.a next to --unwindlib=libunwind
    (//build/config/compiler:runtime_library under is_linux; Android's
    links have their own list, without an unwinder flag).
  - build_defs/testing/native_symbols.bzl: the symbol check passes
    --forbid-exported-unwind-symbols for a library built for Linux
    (check_forbidden_native_symbols.gni under is_linux), so the checks
    of libflutter_linux_gtk.so and of the embedder's
    libflutter_engine.so fail on an exported unwinder symbol, as GN's
    do.
- One conflict the text did not show, in GN itself:
  shell/platform/linux/BUILD.gn lists fl_socket_accessible.h in
  `public` now. Upstream's new fl_socket_accessible_test.cc
  (flutter#196338) includes it; upstream lists the header
  nowhere, and the branch ("[gn] The Linux shell's unlisted headers
  join its lists") had put it among the private sources, so
  `gn gen --check`, which every tools/gn run is, failed on the merged
  tree: "Including a private header". Under Bazel the header would
  have been a private one of the library too, outside the inputs of
  the test's compile (not tried). No gate of mine ran GN's check; a
  tools/gn run for the flag comparison found it, and the gates run
  tools/gn for a host build from now on. shell/platform/linux's
  BUILD.bazel is regenerated with it.

Checked, on this tree with the two commits that follow it (a tool
test of master's that does not compile, and the Slimpeller change),
which is the tree every check below ran on unless it says otherwise:

- The converter: regenerated and --check on this tree itself and on
  the tree with the Slimpeller change (112 generated files current
  both times); on the latter its formatter, analyzer and suite
  (315 tests).
- GN's own check (tools/gn) for a host debug build, a host release
  build and an Android release build on Linux, and for the Mac host
  build and the iOS device build on a Mac.
- check_build_configs.sh, check_generated_bazel_files.sh,
  bazel_ci_test.py (35), engine_build_configs (84), bazel_tools (62),
  buildifier, tools/gn_test.py (7), ci/pylint.sh, ci/format.sh (its
  Python step through yapf directly) and the analyzer over dev/bots:
  these ran before the GN fix and the test fix, and what the two
  touch ran again after them (the generated files' check, gn format,
  buildifier, the analyzer over flutter_tools, the test file).
- The analyzer over flutter_tools, and the tool test files the branch
  touches (391 tests).
- Bazel analysis on Linux: ci_host_debug, host_release_test,
  //:tool_tests //:dart_tests, and every Linux build under its own
  configuration (47). All 352 links of ci_host_debug's graph carry
  the new flag beside --unwindlib=libunwind (345 of them link shared
  libraries). The symbol checks pass the new argument where the
  library is built for Linux (the check of host_debug_desktop and the
  two of host_debug_unopt_impeller_tests: libflutter_linux_gtk.so,
  libflutter_engine.so) and not where it is Android's (the check of
  ci_android_release_arm64).
- On a Mac (the tester's T109): the host build (316
  targets) and its suite (315 of 315 tests), the iOS device build
  ci/ios_debug, and the iOS unit tests on the simulator.

Not run: anything built or linked under Bazel on Linux (analysis
only), so the new link flag and the new symbol check have their first
run on the bots; dev/bots' own tests (the 56 commits change no file
under dev/bots).
chingjun added a commit to chingjun/flutter that referenced this pull request Nov 27, 2026
The branch was rebased onto master (ac8f87e, 56 commits after the
last base, 752015c). The replay changed none of its 631 commits
(their patch ids are the old chain's), and a merge of the same master
into the old head had no conflict in the text. The commits below this
one keep the lock file and the generated files of the old base.

This commit adds what master's 56 commits need. Its tree is the tree
of that merge with the files below.

In it:

- deps.lock.bzl for master's DEPS: the Skia and Dart rolls, and the
  Dart SDK's own dependencies. pub.lock.bzl does not change.
- The converter's output for the two test sources master added:
  impeller/renderer/backend/vulkan/BUILD.bazel
  (pipeline_cache_vk_unittests.cc) and shell/platform/linux/BUILD.bazel
  (fl_socket_accessible_test.cc). The new Dart test files (web_ui, the
  framework) are picked up by globs.
- The port of flutter#196451 ("[Linux] Hide libunwind symbols
  in libflutter_linux_gtk.so") to the two hand-written files that
  mirror the GN it changed:
  - toolchains/cc_toolchain_config.bzl: a Linux link passes
    -Wl,--exclude-libs,libunwind.a next to --unwindlib=libunwind
    (//build/config/compiler:runtime_library under is_linux; Android's
    links have their own list, without an unwinder flag).
  - build_defs/testing/native_symbols.bzl: the symbol check passes
    --forbid-exported-unwind-symbols for a library built for Linux
    (check_forbidden_native_symbols.gni under is_linux), so the checks
    of libflutter_linux_gtk.so and of the embedder's
    libflutter_engine.so fail on an exported unwinder symbol, as GN's
    do.
- One conflict the text did not show, in GN itself:
  shell/platform/linux/BUILD.gn lists fl_socket_accessible.h in
  `public` now. Upstream's new fl_socket_accessible_test.cc
  (flutter#196338) includes it; upstream lists the header
  nowhere, and the branch ("[gn] The Linux shell's unlisted headers
  join its lists") had put it among the private sources, so
  `gn gen --check`, which every tools/gn run is, failed on the merged
  tree: "Including a private header". Under Bazel the header would
  have been a private one of the library too, outside the inputs of
  the test's compile (not tried). No gate of mine ran GN's check; a
  tools/gn run for the flag comparison found it, and the gates run
  tools/gn for a host build from now on. shell/platform/linux's
  BUILD.bazel is regenerated with it.

Checked, on this tree with the two commits that follow it (a tool
test of master's that does not compile, and the Slimpeller change),
which is the tree every check below ran on unless it says otherwise:

- The converter: regenerated and --check on this tree itself and on
  the tree with the Slimpeller change (112 generated files current
  both times); on the latter its formatter, analyzer and suite
  (315 tests).
- GN's own check (tools/gn) for a host debug build, a host release
  build and an Android release build on Linux, and for the Mac host
  build and the iOS device build on a Mac.
- check_build_configs.sh, check_generated_bazel_files.sh,
  bazel_ci_test.py (35), engine_build_configs (84), bazel_tools (62),
  buildifier, tools/gn_test.py (7), ci/pylint.sh, ci/format.sh (its
  Python step through yapf directly) and the analyzer over dev/bots:
  these ran before the GN fix and the test fix, and what the two
  touch ran again after them (the generated files' check, gn format,
  buildifier, the analyzer over flutter_tools, the test file).
- The analyzer over flutter_tools, and the tool test files the branch
  touches (391 tests).
- Bazel analysis on Linux: ci_host_debug, host_release_test,
  //:tool_tests //:dart_tests, and every Linux build under its own
  configuration (47). All 352 links of ci_host_debug's graph carry
  the new flag beside --unwindlib=libunwind (345 of them link shared
  libraries). The symbol checks pass the new argument where the
  library is built for Linux (the check of host_debug_desktop and the
  two of host_debug_unopt_impeller_tests: libflutter_linux_gtk.so,
  libflutter_engine.so) and not where it is Android's (the check of
  ci_android_release_arm64).
- On a Mac (the tester's T109): the host build (316
  targets) and its suite (315 of 315 tests), the iOS device build
  ci/ios_debug, and the iOS unit tests on the simulator.

Not run: anything built or linked under Bazel on Linux (analysis
only), so the new link flag and the new symbol check have their first
run on the bots; dev/bots' own tests (the 56 commits change no file
under dev/bots).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux] libflutter_linux_gtk.so exports _Unwind_* since 3.50.0, C++ exceptions caught inside plugins abort the app

5 participants