[bug] Linux AppImage SIGSEGV on exit: use-after-free in Flutter engine quit_application()

Abierto
#3,013 0 comentarios 0 reacciones 1 asignado Ver en GitHub

@MegatronKing ya está trabajando en esto.

Desde el 2/11/2026.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, flutter, linux
Área
desktop

Línea de trabajo

Start by checking how the Linux AppImage bundles libflutter_linux_gtk.so and confirm its Build ID matches b54eb26c...; the issue names the Flutter engine quit_application() loop and upstream fix commit 2a10ec7c / flutter/engine#55062. The actionable path is upgrading the packaged Flutter engine or backporting the g_list_copy() change, then rebuilding the AppImage. Done means exiting via tray/window close produces no SIGSEGV and no new core dump.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug flutter linux

环境

项 值
版本 Reqable 3.3.6 (build 228),Linux AppImage
发行版 Fedora 44 (KDE Plasma 6)
桌面 / 后端 Wayland (XWayland) + GTK 3.24.52
glib 2.88.4
Flutter 引擎 Flutter 3.19.4 / Dart 3.3.4(2024-04)
libflutter_linux_gtk.so Build ID b54eb26c567d9003c2d9693d4ab03905869051c6

现象

进程在退出时以 SIGSEGV 退出并产生 core dump,KDE 弹 DrKonqi 崩溃提示。可稳定复现(本次会话内 4 次 core,10-20 / 10-28×3 / 10-30 崩溃点完全相同)。触发方式:托盘退出(或关闭窗口)。

应用日志显示 Dart 侧退出清理已完成,紧接着进程崩溃:

10-30 10:13:10.8168 [I][Dart]: Will quit app from tray!
10-30 10:13:10.8301 [I][Dart]: Quiting app.
10-30 10:13:10.8309 [I][Dart]: Resetting proxy.
10-30 10:13:10.8310 [I][Dart]: Proxy was reset to default.
10-30 10:13:10.8405 [I][Dart]: Rest engine was destroyed.

systemd-coredump 原始信息(关键部分):

PID: 125179 (reqable)   Signal: 11 (SEGV)
Storage: /var/lib/systemd/coredump/core.reqable.1000.<boot>.125179.<ts>.zst (present)
#0  g_type_check_instance_cast            (libgobject-2.0.so.0 + 0x2f72f)
#1  n/a                                   (/tmp/.mount_reqabli3Khvk/lib/libflutter_linux_gtk.so + 0x41bd9b)

根因(反汇编 core 已确认)

崩溃点位于 Flutter 引擎 quit_application() 遍历 GtkApplication 窗口列表的循环内。反汇编(基址 0x7ff3cf600000,崩溃返回地址 +0x41bd9b):

call    gtk_application_get_windows
loop:
mov    (%r14),%rdi                ; link->data
call    g_type_check_instance_cast
mov    %rax,%rdi
call    gtk_window_get_type
...
mov    %rax,%r12
...
call    gtk_window_set_application(..., NULL)   ; 会把当前节点从列表摘掉并释放
mov    0x8(%r14),%r14             ; link = link->next   ← 节点已被释放
test   %r14,%r14
jne    loop

寄存器印证是释放后使用:r14 = 0x7ff3ce3c9ad8 <main_arena+24>(已跑进 glibc malloc bin 元数据),传入 type cast 的指针变成 0xff363636…(释放内存被画面颜色等数据复用),随后解引用崩溃。

这段代码在 flutter/engine 早已修复(commit 2a10ec7c,flutter/engine#55062,2024-09),修复方式是先复制列表再遍历:

// List is copied as it will be modified as windows are disconnected from
// the application.
g_autoptr(GList) windows =
    g_list_copy(gtk_application_get_windows(GTK_APPLICATION(app)));

当前打包的引擎没有这个 g_list_copy,因此每次应用请求退出(Dart 侧 System.exitApplication / SystemNavigator.pop)都会走到这段有问题的代码。

影响

崩溃发生在退出流程的最后一小步:Dart 侧已完成重置系统代理、销毁抓包引擎、保存配置,属于“收尾时崩溃”。除产生 core dump / 崩溃弹窗外,未发现数据损坏或功能异常。但每次退出都弹崩溃提示、并写约 15MB core,体验较差。

备注

  • 官网当前 Linux 最新版 3.3.7 的 libflutter_linux_gtk.so Build ID 与 3.3.6 完全一致(同为 b54eb26c567d9003c2d9693d4ab03905869051c6),即仍打包 Flutter 3.19.4,同样受影响。需要升级打包所用的 Flutter 引擎(2024-09 之后的版本)才能根治。
  • 该问题与发行版/显卡/输入法无关(崩溃信息里的 libnss_*、libFcitx5GClient、libgtk-3 只是 systemd-coredump 枚举的“当时加载的模块清单”,并非嫌疑对象)。

复现 / 排查支持

  • 可提供对应 core dump(coredumpctl dump <PID>,约 15MB)与完整反汇编,便于定位。
  • 建议处理方式:升级打包的 Flutter Linux 引擎,或在 quit_application() 中先 g_list_copy() 窗口列表再遍历。
Lenguaje dominante
Sin datos de lenguaje
Estrellas
6.9k
Forks
276
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de reqable/reqable-app

Todos los issues de reqable/reqable-app

Issues similares

Más issues de Desktop Dev

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.