Repository navigation
Description
Steps to reproduce
flutter create --template=plugin --platforms=linux unwind_probe- in
linux/unwind_probe_plugin.ccadd#include <stdexcept>and put this at the top ofunwind_probe_plugin_register_with_registrar:
try {
throw std::runtime_error("thrown inside the plugin");
} catch (const std::exception& e) {
g_print("unwind_probe: caught: %s\n", e.what());
}cd example && flutter build linux --release(same with--debug)- run
build/linux/x64/release/bundle/unwind_probe_example
done with the official tarballs flutter_linux_3.47.9-stable.tar.xz and flutter_linux_3.50.0-stable.tar.xz on a clean Ubuntu 24.04 x64, each project created by its own sdk, two runs each
Expected results
the exception is caught inside the plugin, like on 3.47.9:
unwind_probe: caught: thrown inside the plugin
Actual results
on 3.50.0 the app aborts (SIGABRT, debug and release):
terminate called after throwing an instance of 'std::runtime_error'
terminate called recursively
real world case: flutter_secure_storage_linux throws LibsecretError when there is no unlocked keyring and catches it in its method call handler, so on 3.50.0 the app dies at start on any machine without one instead of getting a PlatformException
libflutter_linux_gtk.so exports an unwinder since 3.50.0:
$ nm -D --defined-only 3.47.9/flutter/bin/cache/artifacts/engine/linux-x64-release/libflutter_linux_gtk.so | grep -c _Unwind_
0
$ nm -D --defined-only 3.50.0/flutter/bin/cache/artifacts/engine/linux-x64-release/libflutter_linux_gtk.so | grep _Unwind_
0000000001037250 T _Unwind_DeleteException
00000000010370b0 T _Unwind_ForcedUnwind
00000000010372b0 T _Unwind_GetGR
0000000001037370 T _Unwind_GetIP
0000000001037140 T _Unwind_GetLanguageSpecificData
00000000010371e0 T _Unwind_GetRegionStart
0000000001036610 T _Unwind_RaiseException
0000000001036cd0 T _Unwind_Resume
0000000001037310 T _Unwind_SetGR
00000000010373d0 T _Unwind_SetIP
same 10 symbols in linux-x64 and linux-x64-profile, 0 in all three on 3.47.9
LD_DEBUG=bindings on the 3.50.0 release build shows libstdc++ and even libgcc_s throwing through the engines copy:
binding file /lib/x86_64-linux-gnu/libstdc++.so.6 [0] to .../bundle/lib/libflutter_linux_gtk.so [0]: normal symbol `_Unwind_RaiseException' [GCC_3.0]
binding file /lib/x86_64-linux-gnu/libgcc_s.so.1 [0] to .../bundle/lib/libflutter_linux_gtk.so [0]: normal symbol `_Unwind_RaiseException' [GCC_3.0]
so the plugin is compiled against libstdc++/libgcc but unwinds with the llvm libunwind inside the engine, and the handler is never found
looks like it comes from #192607 (2553f89), engine/src/build/config/compiler/BUILD.gn at 3.50.0, lines 640 to 646:
ldflags += [ "-nostdlib++" ]
if (is_linux) {
# Our custom libcxx doesn't include the unwinder, which is included in
# libc++.a. Link the libunwind directly.
ldflags += [ "--unwindlib=libunwind" ]
}on 3.47.9 linux was excluded there (if (!is_linux) { ldflags += [ "-nostdlib++" ] }). nothing hides the static libunwind, so its symbols end up in the dynamic symbol table. i guess -Wl,--exclude-libs,libunwind.a (or a version script) for the linux shared library would fix it, didnt build the engine to verify that. testing/symbols/verify_exported.dart only checks libflutter_engine.so on linux, not libflutter_linux_gtk.so, probably why it wasnt caught
workaround for apps: link libgcc_s first in linux/runner/CMakeLists.txt, then its unwinder wins the lookup again and the probe catches on 3.50.0 (debug and release, two runs each):
target_link_options(${BINARY_NAME} PRIVATE
"LINKER:--push-state,--no-as-needed,-lgcc_s,--pop-state")maybe related to #188877, same area (static runtime of the engine colliding with the host process) but a different symptom
Code sample
Code sample
linux/unwind_probe_plugin.cc of a fresh flutter create --template=plugin --platforms=linux unwind_probe, only change:
#include <stdexcept>
void unwind_probe_plugin_register_with_registrar(FlPluginRegistrar* registrar) {
try {
throw std::runtime_error("thrown inside the plugin");
} catch (const std::exception& e) {
g_print("unwind_probe: caught: %s\n", e.what());
}
// ... generated code unchanged
}Flutter Doctor output
Doctor output
[!] Flutter (Channel stable, 3.50.0, on Ubuntu 24.04.5 LTS 7.2.12-orbstack-00394-gbecdd6130068, locale en_US.UTF-8)
• Flutter version 3.50.0 on channel stable
• Framework revision ab2912035e (2 days ago), 2026-11-09 08:50:21 -0800
• Engine revision 371f77202a
• Dart version 3.14.0
• DevTools version 2.61.0
[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 18.1.3 (1ubuntu1)
• cmake version 3.28.3
• ninja version 1.11.1
• pkg-config version 1.8.1works on 3.47.9 (framework c197ca5, engine 89c39ed, Dart 3.13.7), same machine and toolchain. the [!] is only "flutter not on PATH"
Activity
suryaKommana2662 commentedon Nov 12, 2026
@patrickweh Thanks for report. Routing to the
team-linuxfor further investigation.chore: restore CI on Flutter 3.50 / Dart 3.14 (#1025)
fix(cbl): keep C++ exceptions working in Flutter 3.50 Linux apps (#1028)
CHAT-126: link libgcc_s first so Linux plugins can catch their except…
Maksim-Nikolaev commentedon Nov 20, 2026
Same root cause also breaks Rust libraries loaded through
dart:ffi(reported in #197043, closing as a duplicate of this one).std::backtrace::Backtrace::force_capture()crashes with SIGSEGV and a panic insidecatch_unwindaborts withfailed to initiate panic, error 3. flutter_rust_bridge captures a backtrace for every Rust error, so the first error closes the app. The engine exports 10_Unwind_*functions but not_Unwind_Backtrace, so Rust walks the stack with libgcc and reads the context with the engine's_Unwind_GetIP.Repro: https://github.com/Maksim-Nikolaev/flutter-unwinder-repro (
./check.shruns both cases)Tested fix: keep the static unwinder private in
engine/src/flutter/shell/platform/linux/BUILD.gn:shared_library("flutter_linux_gtk") { deps = [ ":flutter_linux" ] - ldflags = [ "-Wl,-rpath,\$ORIGIN" ] + ldflags = [ + "-Wl,-rpath,\$ORIGIN", + "-Wl,--exclude-libs,libunwind.a", + ]With a 3.50.0 engine built this way the library exports no
_Unwind_*/unw_*symbols and Impeller starts as usual. Results, two runs each, x86_64 only:terminate called after throwing an instance of 'std::runtime_error', exit 134unwind_probe: caught: thrown inside the pluginBacktrace::force_capture()catch_unwindWorkaround until a release has the fix, in
linux/runner/CMakeLists.txt:@dcharkes compared two options in #197043 (comment): exporting the full unwinder (possible size increase, needs an automigration) versus hiding it as above (no migration, same size as today). The diff above is the second one. Happy to send a PR for it.
[Linux] Hide libunwind symbols in libflutter_linux_gtk.so (flutter#19…
fix(player): link libgcc_s ahead of the Flutter 3.50 engine on Linux
h4rm00n commentedon Nov 24, 2026
One more affected category that neither C++ plugins nor Rust cover: libmpv built against LuaJIT — the default for system mpv on Arch/Debian/Ubuntu/Fedora. This one dies with SIGSEGV rather than abort, and it hits audio-only apps.
YesPlayMusic (CI pins
FLUTTER_VERSION: "3.50.0") plays audio via media_kit, whichdlopen()s the systemlibmpv.so. On Arch (mpv 1:0.42.0-3, luajit 2.1.1795119671+96f7b29-1), mpv's builtin Lua scripts abort JIT trace recording routinely (lj_trace_err→lj_err_throw→_Unwind_RaiseException); normally this unwinds silently inside LuaJIT. With the 3.50 engine exporting its unwinder, LuaJIT's GOT ends up mixed — read back from core dumps of the running app:_Unwind_RaiseException/_Unwind_GetIP/_Unwind_SetIP/_Unwind_SetGR/_Unwind_DeleteException→libflutter_linux_gtk.so_Unwind_GetCFA(not exported by the engine) →libgcc_s.so.1So
_Unwind_RaiseExceptionbuilds an LLVM-libunwind context, then LuaJIT's personality routine reads that context with libgcc's_Unwind_GetCFA; the twostruct _Unwind_Contextlayouts differ, so libgcc returns garbage and LuaJIT'serr_unwinddereferences it — SIGSEGV,si_code=SI_KERNEL. The trigger is stochastic (JIT hot-spot counters), so it presents as a random crash; in our logs it most often fires when a track ends and playback switches to the next file, but one of five captured cores crashed duringmpv_initialize.Reproduced without the GUI app: a trivial C program linked against
libflutter_linux_gtk.sothatdlopen("libmpv.so")s and plays short audio files to EOF reliably segfaults; the same program withLD_PRELOAD=libgcc_s.so.1runs indefinitely. On the real app, the-lgcc_slink-order workaround suggested in this issue fixes it as well (A/B on one machine: 4/4 runs crash unpatched, 4/4 survive patched, ~10 end-of-track transitions per run).Looking forward to #196451 landing in a stable release — it would fix this whole class of failures for Linux apps that embed native libraries.
修复 Linux 上放完一首切下一首时的段错误
Kataglyphis commentedon Nov 27, 2026
3.50.1 still ships the exported unwinder, so this still aborts apps on stable. #196451 is on master only: its merge commit
203c0c42is on neitherflutter-3.50-candidate.0(stable) norflutter-3.51-candidate.0(beta), and 3.51.0-0.2.pre does not have it either.Could someone with triage rights add
cp: stableandcp: betato #196451? Its merge commit already carriescp-trigger.yml.What 3.50.1 exports (
linux-x64-releaseandlinux-x64-debugfromstorage.googleapis.com/flutter_infra_release/flutter/<engine>/):The 31 are ten
_Unwind_*functions (_Unwind_DeleteException,_Unwind_ForcedUnwind,_Unwind_GetGR,_Unwind_GetIP,_Unwind_GetLanguageSpecificData,_Unwind_GetRegionStart,_Unwind_RaiseException,_Unwind_Resume,_Unwind_SetGR,_Unwind_SetIP), four__unw_*(__unw_add_dynamic_eh_frame_section,__unw_add_dynamic_fdeand their tworemovetwins) and seventeenunw_*._Unwind_GetIPInfoand_Unwind_Backtraceare not exported, so they still come from libgcc_s.Smallest reproduction, no Flutter project needed (
repro.cc):flutter-firstgcc-firstterminate called after throwing an instance of 'std::runtime_error',terminate called recursively, SIGABRT (134)caughtcaughtcaughtcaughtUbuntu, GCC 15.2, x86_64. In a real app the core's stack is
__cxa_throw→_Unwind_RaiseException(libflutter_linux_gtk.so) →__gxx_personality_v0→__cxa_call_terminate, for an exception the throwing library catches itself.The workaround every Linux app needs until a release carries the fix, in
linux/CMakeLists.txtbefore the runner linksflutter:Expected: the engine exports none of libunwind's symbols. #196451 does that with
-Wl,--exclude-libs,libunwind.a; hidden visibility for the statically linked libunwind would do the same.feat(flutter): a Flutter Linux runner loads libgcc_s's unwinder befor…