[Linux] DEBUG_PRINT_LAYOUT is left on in fl_keyboard_manager.cc; its loop looks up keycodes 0-7 and crashes on an X display without XKB (ssh -X)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
Direzione di ricerca
Leggi engine/src/flutter/shell/platform/linux/fl_keyboard_manager.cc, in particolare la definizione di DEBUG_PRINT_LAYOUT e il ciclo guarantee_layout() descritto nell’issue. Riproduci il problema con un display X non attendibile seguendo i passaggi forniti, poi verifica che la prima pressione di un tasto non provochi più un arresto anomalo quando il ciclo di debug è disabilitato o reso facoltativo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Steps to reproduce
On Linux, a Flutter app segfaults on its first key press when it runs as an untrusted X client, for example over ssh -X with OpenSSH's default ForwardX11Trusted no (the default on macOS). The same app works as a trusted client (ssh -Y).
Minimal repro on Ubuntu 22.04 or 24.04, Flutter 3.47.7 stable:
flutter create --platforms=linux app- In
linux/runner/my_application.cc, callfl_dart_project_set_enable_impeller(project, FALSE);(so the software renderer works under Xvfb). flutter build linux --release- Start an X server with the SECURITY extension and make an untrusted cookie:
xauth -f t add :77 . $(mcookie) Xvfb :77 -auth t +extension SECURITY -noreset & XAUTHORITY=t xauth -f u generate :77 . untrusted timeout 3600 - Run the app as the untrusted client and type one key as a trusted one:
DISPLAY=:77 XAUTHORITY=u FLUTTER_LINUX_RENDERER=software build/linux/x64/release/bundle/app & DISPLAY=:77 XAUTHORITY=t xdotool search --sync --onlyvisible --name app windowfocus --sync DISPLAY=:77 XAUTHORITY=t xdotool type a
Expected results
The key press reaches the app, as it does with XAUTHORITY=t (a trusted client).
Actual results
The app is killed by SIGSEGV in gdk_x11_keymap_lookup_key.
Cause: engine/src/flutter/shell/platform/linux/fl_keyboard_manager.cc line 19 has #define DEBUG_PRINT_LAYOUT, which has been on since flutter/engine#32665 (April 2022) and is still on in master. With it on, guarantee_layout() runs for (uint16_t keycode = 0; keycode < 128; keycode += 1), calling convert_key_to_char and so gdk_keymap_lookup_key() for keycodes 0 to 127 on the first key press of each group. It builds debug_layout_data, which is never printed.
X keycodes start at the display's min_keycode (8 here). With XKEYBOARD, GDK tolerates keycode 0. An untrusted client is not given XKEYBOARD, so GDK uses the core keymap, computes (0 - min_keycode) unsigned, and reads out of bounds.
Suggested fix: remove the #define (or make it opt-in). Optionally, convert_key_to_char could also skip keycodes outside the display's XDisplayKeycodes range.
Code sample
The stock flutter create app, with only the Impeller change in step 2.
Logs
Stack, Ubuntu 24.04, GTK 3.24.41-4ubuntu1.3, gdb with debuginfod:
#0 gdk_x11_keymap_lookup_key (keymap=GdkX11Keymap, key=0x7fffffffc840) at gdk/x11/gdkkeys-x11.c:1063
#1 libflutter_linux_gtk.so (guarantee_layout / convert_key_to_char, inlined)
#2 libflutter_linux_gtk.so (fl_keyboard_manager_handle_event path)
#3-#7 g_signal_emit key-press-event on FlView
#8 gtk_widget_event_internal (FlView)
#9 gtk_window_propagate_key_event
#10 gtk_window_key_press_event
#16-#19 gtk_widget_event_internal / propagate_event / gtk_main_do_event
#21 _gdk_event_emit
#23 gdk_event_source_dispatch
#24-#28 g_main_context_iteration / g_application_run
#29 main
At the crash: *key = {keycode = 0, group = 0, level = 0}, keymap min_keycode = 8, max_keycode = 255, keysyms_per_keycode = 7, xkb_desc = NULL, rax = 0xffffffc8 (that is (0 - 8) * 7). A breakpoint on gdk_keymap_lookup_key counts 354 calls on the first key: keycodes 0 to 127 at levels 0 and 1 (the debug loop) plus the 49 layout goals. The same crash happens on Ubuntu 22.04 (GTK 3.24.33).
Flutter Doctor output
Flutter 3.47.7 stable, engine d8a2d6c768, on Ubuntu 22.04 and 24.04 (GitHub Actions runners).
- Lingua principale
- Dart
- Stelle
- 181k
- Fork
- 33.3k
- Merge medio
- 1g 20h
- PR unite (30g)
- 281
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di flutter/flutter
-
waiting for response
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
flutter/flutter#195626 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[cupertino_ui] A disabled segment doesn't tell screen readers it's disabledForse già presa @joellemd l’ha presa 1 giorno fa. Apertaa: accessibility has reproducible steps p: cupertino_ui package team-design
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
[cupertino_ui] A disabled CupertinoButton doesn't tell screen readers it's disabledForse già presa @joellemd l’ha presa 1 giorno fa. Apertaa: accessibility p: cupertino_ui package team-design
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
flutter/flutter#195514 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
SweepGradient.lerp clamps valid negative angles during interpolationForse già presa @Shubham-Padkonde l’ha presa 4 giorni fa. Apertaa: animation c: rendering framework team-framework
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
flutter/flutter#195470 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
fyi-ecosystem has reproducible steps p: webview package platform-ios team-ios
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
flutter/flutter#195465 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di flutter/flutter
Issue simili
-
dart easy first-contributor first-contributors good first issue help wanted up-for-grabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
fork-commit-merge/fork-commit-merge#8563 ·
I maintainer di solito rispondono entro 1 giorno
-
from.page-issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
bannzai/Pilll#2080 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
mollykitten/waveform#112 ·
I maintainer di solito rispondono entro 1 giorno
-
auto-implement-claude
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno