Crash in wayland code opening eeschema or pcbnew from project manager on dual-screen mixed-DPI setup
I have a fairly fresh KiCad build running in gnome on wayland on an up-to-date Archlinux. It works fine on one machine, but crashes on another machine. The main difference between the two is that one has two displays both set at 100% UI scale, the other has two displays with one set to 100% and the other set to 200% UI scale. Since I have seen lots of bugginess because of that before, I suspect that to be the root trigger of this issue.
On the "bad" setup, every time I open eeschema or pcbnew through the project manager, it crashes. The schematic editor window manages to open, briefly shows the schematic, then, all KiCad windows close and the process exits with exit code 1 from an abort somewhere deep down in gdk.
I obtained a gdb backtrace by break'ing on _exit
:
Backtrace, click to open
#0 0x00007ffff3ef3650 in _exit () at /usr/lib/libc.so.6 #1 0x00007ffff6b6aa98 in _gdk_wayland_display_queue_events (display=) at ../gtk/gdk/wayland/gdkeventsource.c:205 #2 _gdk_wayland_display_queue_events (display=) at ../gtk/gdk/wayland/gdkeventsource.c:193 #3 0x00007ffff6b36fa9 in gdk_display_get_event (display=0x555555ee21e0) at ../gtk/gdk/gdkdisplay.c:442 #4 0x00007ffff6b72208 in gdk_event_source_dispatch (base=, callback=, data=) at ../gtk/gdk/wayland/gdkeventsource.c:120 #5 0x00007ffff4d40199 in g_main_dispatch (context=0x555555eefbe0) at ../glib/glib/gmain.c:3344 #6 0x00007ffff4d9f3bf in g_main_context_dispatch_unlocked (context=0x555555eefbe0) at ../glib/glib/gmain.c:4152 #7 g_main_context_iterate_unlocked.isra.0 (context=0x555555eefbe0, block=block@entry=1, dispatch=dispatch@entry=1, self=) at ../glib/glib/gmain.c:4217 #8 0x00007ffff4d40dc7 in g_main_loop_run (loop=0x5555560f8290) at ../glib/glib/gmain.c:4419 #9 0x00007ffff51ed2bf in gtk_main () at ../gtk/gtk/gtkmain.c:1329 #10 0x00007ffff792ef76 in wxGUIEventLoop::DoRun (this=0x555556cfd610) at /usr/src/debug/wxwidgets/wxWidgets-3.2.4/src/gtk/evtloop.cpp:61 #11 0x00007ffff70b3e52 in wxEventLoopBase::Run (this=0x555556cfd610) at /usr/src/debug/wxwidgets/wxWidgets-3.2.4/src/common/evtloopcmn.cpp:87 #12 0x00007ffff708ff78 in wxAppConsoleBase::MainLoop (this=0x555555ed99f0) at /usr/src/debug/wxwidgets/wxWidgets-3.2.4/src/common/appbase.cpp:381 #13 0x0000555555662a2e in APP_KICAD::OnRun (this=0x555555ed99f0) at /home/jaseg/ref/kicad/kicad/kicad.cpp:476 #14 0x00007ffff70f1410 in wxEntry (argc=, argv=) at /usr/src/debug/wxwidgets/wxWidgets-3.2.4/src/common/init.cpp:497 #15 0x000055555565dab7 in main (argc=1, argv=0x7fffffffd218) at /home/jaseg/ref/kicad/kicad/kicad.cpp:572
The exit results from this line in gdk:
https://github.com/GNOME/gtk/blob/main/gdk/wayland/gdkeventsource.c#L222
...which points to the Wayland compositor being unhappy with something KiCad sends it. Looking at the session journal during the crash using journalctl --user --follow
, we see that gnome-shell emits two error messages when KiCad crashes:
Apr 19 11:27:29 straumli gnome-shell[2028]: WL: error in client communication (pid 181742)
Apr 19 11:27:29 straumli gnome-shell[2028]: meta_window_set_stack_position_no_sync: assertion 'window->stack_position >= 0' failed
The second message only occassionally appears, and I suspect it is unrelated to the problem, and just results from gnome-shell being confused that some windows just disappeared into thin air.
Here's the last few lines of output of KiCad run with WAYLAND_DEBUG=1
, the complete file is attached here: wl-debug:
Last lines of log, click to open
[3394962.165] wl_display#1.delete_id(69) [3394962.172] wl_callback#69.done(187383) [3394962.192] -> zwp_linux_dmabuf_v1#38.create_params(new id zwp_linux_buffer_params_v1#69) [3394962.352] -> zwp_linux_buffer_params_v1#69.add(fd 20, 0, 0, 7168, 33554436, 1079097857) [3394962.383] -> zwp_linux_buffer_params_v1#69.add(fd 21, 1, 14680064, 4096, 33554436, 1079097857) [3394962.396] -> zwp_linux_buffer_params_v1#69.create_immed(new id wl_buffer#66, 3464, 1999, 909199186, 0) [3394962.413] -> zwp_linux_buffer_params_v1#69.destroy() [3394962.449] -> wl_surface#59.attach(wl_buffer#66, 0, 0) [3394962.463] -> wl_surface#59.damage(0, 0, 2147483647, 2147483647) [3394962.475] -> wl_surface#59.commit() [3394962.488] -> wl_display#1.sync(new id wl_callback#70) [3394967.369] -> wl_surface#57.attach(wl_buffer#61, 0, 0) [3394967.389] -> wl_surface#57.set_buffer_scale(1) [3394967.393] -> wl_surface#57.damage(0, 0, 3840, 2160) [3394967.398] -> xdg_toplevel#53.set_min_size(500, 400) [3394967.401] -> xdg_toplevel#53.set_max_size(134217727, 134217727) [3394967.405] -> xdg_surface#54.set_window_geometry(0, 0, 3840, 2160) [3394968.650] -> wl_surface#57.attach(wl_buffer#61, 0, 0) [3394968.661] -> wl_surface#57.set_buffer_scale(1) [3394968.666] -> wl_surface#57.damage(0, 64, 3839, 34) [3394968.671] -> xdg_toplevel#53.set_min_size(500, 400) [3394968.675] -> xdg_toplevel#53.set_max_size(134217727, 134217727) [3394968.679] -> xdg_surface#54.set_window_geometry(0, 0, 3840, 2160) [3394971.023] -> wl_surface#57.attach(wl_buffer#61, 0, 0) [3394971.034] -> wl_surface#57.set_buffer_scale(1) [3394971.038] -> wl_surface#57.damage(307, 98, 34, 1049) [3394971.041] -> wl_surface#57.damage(1, 1147, 300, 950) [3394971.044] -> wl_surface#57.damage(307, 1147, 34, 950) [3394971.047] -> xdg_toplevel#53.set_min_size(500, 400) [3394971.050] -> xdg_toplevel#53.set_max_size(134217727, 134217727) [3394971.054] -> xdg_surface#54.set_window_geometry(0, 0, 3840, 2160) [3394972.039] -> wl_surface#57.attach(wl_buffer#61, 0, 0) [3394972.050] -> wl_surface#57.set_buffer_scale(1) [3394972.054] -> wl_surface#57.damage(3806, 98, 34, 1999) [3394972.058] -> xdg_toplevel#53.set_min_size(500, 400) [3394972.061] -> xdg_toplevel#53.set_max_size(134217727, 134217727) [3394972.065] -> xdg_surface#54.set_window_geometry(0, 0, 3840, 2160) [3394972.224] -> wl_subsurface#68.set_position(342, 99) [3395000.215] wl_display#1.error(wl_surface#59, 2, "Buffer size (3464x1999) must be an integer multiple of the buffer_scale (2).")
Steps to reproduce
- Connect two displays to the computer, set one to 100% UI scale, the other to 200% in gnome's display settings
- Open a project in the KiCad project manager
- Open a schematic from the project
- kicad crashes
- Check at the end of
journalctl --user -n 100
for the compositor-side error message.
KiCad Version
Fairly fresh build from git, commit id bf16f757 on an up-to-date Archlinux.
Application: KiCad x86_64 on x86_64
Version: 8.0.0~rc1, debug build
Libraries:
wxWidgets 3.2.4
FreeType 2.13.2
HarfBuzz 8.3.0
FontConfig 2.15.0
libcurl/8.7.1 OpenSSL/3.2.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 libssh2/1.11.0 nghttp2/1.61.0 nghttp3/1.2.0
Platform: Arch Linux, 64 bit, Little endian, wxGTK, Wayland, gnome, wayland
Build Info:
Date: Jan 17 2024 14:04:05
wxWidgets: 3.2.4 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.83.0
OCC: 7.7.2
Curl: 8.5.0
ngspice: 40
Compiler: GCC 13.2.1 with C++ ABI 1018
Build settings:
KICAD_USE_EGL=ON
KICAD_STDLIB_DEBUG=OFF
KICAD_STDLIB_LIGHT_DEBUG=OFF
KICAD_SANITIZE_ADDRESS=OFF
KICAD_SANITIZE_THREADS=OFF