Adding repro instructions (I hit the same bug but found that it was already
filed)
It takes about 2 minutes in a fresh container. It starts its own headless
sway, D-Bus session bus and accessibility bus, so nothing touches a running
desktop session.
1. Start a container and install the packages:
docker run --rm -it debian:sid
echo 'deb http://deb.debian.org/debian-debug sid-debug main' >
/etc/apt/sources.list.d/debug.list
apt update
apt install -y --no-install-recommends sway wtype python3-gi
gir1.2-gtk-3.0 gir1.2-atspi-2.0 at-spi2-core dbus dbus-bin gdb procps
libgtk-3-0t64-dbgsym
The -dbgsym package is only needed for symbolic backtraces. For trixie,
use debian:trixie and trixie-debug.
2. Create these three files in one directory.
app.py, a GTK 3 window with an entry:
#!/usr/bin/env python3
# A GTK 3 window with an entry; quits after the number of seconds given
(default 20).
import sys
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib
win = Gtk.Window(title="a11y-race")
win.add(Gtk.Entry())
win.connect("destroy", Gtk.main_quit)
win.show_all()
GLib.timeout_add_seconds(int(sys.argv[1]) if len(sys.argv) > 1 else 20,
Gtk.main_quit)
Gtk.main()
client.py, an AT-SPI client that connects and then exits:
#!/usr/bin/env python3
# An AT-SPI client that asks app.py (or the application named in $1)
one question and
# exits (status 0 if it found it).
# The question makes app.py's AT-SPI bridge count this process as a
client and add its
# ATK key listener; when the process exits, the bridge removes that
listener again.
import sys
import gi
gi.require_version("Atspi", "2.0")
from gi.repository import Atspi
desktop = Atspi.get_desktop(0)
name = sys.argv[1] if len(sys.argv) > 1 else "app.py"
for i in range(desktop.get_child_count()):
app = desktop.get_child_at_index(i)
if app is not None and app.get_name() == name:
app.get_child_count()
sys.exit(0)
sys.exit(1)
repro.sh, which runs headless sway, types into the window with wtype and
keeps starting AT-SPI clients:
#!/bin/sh
# repro.sh [RUNS] [SECONDS]: start a headless sway, then RUNS times:
start app.py,
# type into it with wtype while short-lived AT-SPI clients (client.py)
come and go,
# for at most SECONDS. Counts the runs where app.py died of SIGSEGV.
# Run it inside a D-Bus session: dbus-run-session -- sh repro.sh 40 8
RUNS=${1:-20}; SECS=${2:-8}
HERE=$(cd "$(dirname "$0")" && pwd)
export XDG_RUNTIME_DIR=$(mktemp -d) WLR_BACKENDS=headless
WLR_RENDERER=pixman WLR_LIBINPUT_NO_DEVICES=1
chmod 700 "$XDG_RUNTIME_DIR"
printf 'output HEADLESS-1 resolution 1280x800\n' >
"$XDG_RUNTIME_DIR/sway.cfg"
sway -c "$XDG_RUNTIME_DIR/sway.cfg" >"$XDG_RUNTIME_DIR/sway.log" 2>&1 &
for i in $(seq 1 50); do ls "$XDG_RUNTIME_DIR"/wayland-? >/dev/null
2>&1 && break; sleep 0.1; done
export WAYLAND_DISPLAY=$(basename "$(ls "$XDG_RUNTIME_DIR"/wayland-? |
head -1)") XDG_SESSION_TYPE=wayland GDK_BACKEND=wayland
crashes=0
for run in $(seq 1 "$RUNS"); do
python3 "$HERE/app.py" "$SECS" 2>/dev/null & app=$!
sleep 1.5
( found=0; while kill -0 $app 2>/dev/null; do python3
"$HERE/client.py" 2>/dev/null && found=$((found+1)); done; echo "$found" >
"$XDG_RUNTIME_DIR/found" ) & clients=$!
( while kill -0 $app 2>/dev/null; do wtype -d 15
abcdefghijklmnopqrstuvwxyz 2>/dev/null; done ) & typer=$!
wait $app; rc=$?
wait $clients $typer 2>/dev/null
[ $rc = 139 ] && crashes=$((crashes+1))
echo "run $run: exit $rc, AT-SPI clients that reached app.py: $(cat
"$XDG_RUNTIME_DIR/found")"
done
echo "SIGSEGV in $crashes of $RUNS runs"
3. Run it: 40 runs of up to 8 s each.
dbus-run-session -- sh repro.sh 40 8
Expected on 3.24.52-3: "run N: exit 139" lines and "SIGSEGV in 40 of 40
runs". Each run crashes after 3 to 56 client exits (median 12), which is 1
or 2 seconds.
With e6372d29: every run ends with exit 0 after 8 s, with about 80
client exits per run.
To see the crash in gdb, run app.py as `gdb -batch -ex run -ex bt --args
python3 app.py 8`, with the client loop and the wtype loop from repro.sh
running alongside. On sid, 3.24.52-3:
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007f69764bb2f8 in _gtk_accessibility_key_snooper
(widget=widget@entry=0xd4a4f0, event=event@entry=0x1075db0) at
../../../gtk/a11y/gtkaccessibilityutil.c:154
#0 _gtk_accessibility_key_snooper (widget=widget@entry=0xd4a4f0,
event=event@entry=0x1075db0) at ../../../gtk/a11y/gtkaccessibilityutil.c:154
#1 gtk_invoke_key_snoopers (grab_widget=0xd4a4f0, event=0x1075db0) at
../../../gtk/gtkmain.c:2451
#2 gtk_main_do_event (event=0x1075db0) at ../../../gtk/gtkmain.c:1869
#3 gtk_main_do_event (event=<optimized out>) at
../../../gtk/gtkmain.c:1694
#4 _gdk_event_emit (event=event@entry=0x1075db0) at
../../../gdk/gdkevents.c:73
#5 gdk_event_source_dispatch (base=<optimized out>,
callback=<optimized out>, data=<optimized out>) at
../../../gdk/wayland/gdkeventsource.c:124
On trixie, 3.24.49-3, it crashed in try 16, at line 152 (`listener =
l->data`, where the freed node's next pointer was garbage):
_gtk_accessibility_key_snooper (widget=widget@entry=0xf2d510,
event=event@entry=0x108ca50) at ../../../gtk/a11y/gtkaccessibilityutil.c:152
#1 gtk_invoke_key_snoopers (grab_widget=0xf2d510, event=0x108ca50) at
../../../gtk/gtkmain.c:2448
#2 gtk_main_do_event (event=0x108ca50) at ../../../gtk/gtkmain.c:1866
#4 _gdk_event_emit (event=event@entry=0x108ca50) at
../../../gdk/gdkevents.c:73
#5 gdk_event_source_dispatch (...) at
../../../gdk/wayland/gdkeventsource.c:124
These are the frames from the upstream commit message.
Crash rates (reproducer above, 40 runs each)
--------------------------------------------
build SIGSEGV
sid: libgtk-3-0t64 3.24.52-3 from the archive 40/40
sid: 3.24.52-3 source rebuilt as is (7 patches) 40/40
sid: 3.24.52-3 source rebuilt + e6372d29 0/40
trixie: libgtk-3-0t64 3.24.49-3 from the archive 2/40
The rebuilt libraries are plain meson builds of libgtk-3.so only (`apt-get
source`, `quilt push -a`, the patch on top, no introspection, file print
backend), loaded with LD_LIBRARY_PATH. The unpatched rebuild crashes like
the archive library, so the build configuration isn't what stops the crash.
The same test on Ubuntu 26.04 (3.24.52-0ubuntu1) gives 40/40 as packaged
and 0/40 with e6372d29.