Repository navigation
[Linux] Hide libunwind symbols in libflutter_linux_gtk.so - #196451
Conversation
There was a problem hiding this comment.
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.
cbe9e74 to
77ad0e1
Compare
|
An existing Git SHA, To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with |
18befb7 to
f5124b2
Compare
f5124b2 to
4c781cf
Compare
|
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.
|
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
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.
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).
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).
Because the engine library is loaded before
libgcc_s,libstdc++andlibgcc_sbind_Unwind_RaiseExceptionto the engine's copy (see theLD_DEBUG=bindingsoutput in the issue). A plugin that throws and catches its own C++ exception then aborts withterminate called after throwing an instance of .... One real-world case:flutter_secure_storage_linuxcrashes the app at startup on machines without an unlocked keyring, where it should return aPlatformException.Changes
build/config/compiler/BUILD.gn: add-Wl,--exclude-libs,libunwind.anext 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-symbolsflag, turned on for Linux. It runsllvm-nm --dynamic --defined-onlyand fails on any exported symbol from libunwind (_Unwind_*,unw_*,__unw_*,__register_frame*,__deregister_frame*). This coverslibflutter_linux_gtk.so, whichverify_exported.dartdoesn't check on Linux, andlibflutter_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.--exclude-libsflag removed,check_native_symbolsfails and lists the leaked symbols.unwind_probe: caught: thrown inside the pluginwith a local engine.Fixes #196402
Pre-launch Checklist
///).