Issue with GL after upgrading to 20.10

I’ve been testing my alacritty snap (with classic confinement) for a while and it worked just fine on 20.04 until I upgraded to 20.10 recently. Once upgraded to 20.10, I started to see these errors:

$ alacritty -vv                                                                                                                                                                                                                                                                                            ⏎ [ master ]
[2021-01-20 16:48:39.601511358] [INFO ] [alacritty] Welcome to Alacritty
Created log file at "/tmp/Alacritty-463916.log"
[2021-01-20 16:48:39.602446792] [INFO ] [alacritty] Configuration files loaded from:
[2021-01-20 16:48:39.602456759] [INFO ] [alacritty]   "/home/kanata/.config/alacritty/alacritty.yml"
[2021-01-20 16:48:39.613765493] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Regular, load_flags: TARGET_LIGHT, render_mode: "Normal", lcd_filter: 1 }
[2021-01-20 16:48:39.614842864] [DEBUG] [alacritty] Estimated DPR: 1
[2021-01-20 16:48:39.614857890] [DEBUG] [alacritty] Estimated window size: Some(PhysicalSize { width: 1400, height: 825 })
[2021-01-20 16:48:39.614865213] [DEBUG] [alacritty] Estimated cell size: 7 x 15
libGL error: MESA-LOADER: failed to open iris (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open iris (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: swrast
libEGL warning: MESA-LOADER: failed to open iris (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

libEGL warning: MESA-LOADER: failed to open iris (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

libEGL warning: MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

libEGL warning: MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

libEGL warning: MESA-LOADER: failed to open iris (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

libEGL warning: MESA-LOADER: failed to open iris (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

libEGL warning: MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

libEGL warning: MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

[2021-01-20 16:48:39.651793994] [ERROR] [alacritty] Alacritty encountered an unrecoverable error:

        Error creating GL context; Received multiple errors. Errors: `[OsError("eglInitialize failed"), OsError("GL context creation failed")]`

I thought that it might be related to updated GL in 20.10 so decided to embed them but then I started to see segmentation fault (core dumped) errors during application start. I ran it with gdb and got the following stacktrace:

Thread 1 "alacritty" received signal SIGSEGV, Segmentation fault.
0x00007fd70845993d in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
(gdb) bt
#0  0x00007fd70845993d in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#1  0x00007fd70a43b375 in dl_iterate_phdr () from /snap/alacritty/x1/bin/../lib/x86_64-linux-gnu/libc.so.6
#2  0x00007fd7084599cc in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#3  0x00007fd7084fabd6 in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007fd7084fa85c in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007fd707a1347b in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#6  0x00007fd70804ad2c in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#7  0x00007fd707a15eac in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#8  0x00007fd707f6e3b5 in ?? () from /snap/alacritty/x1/usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#9  0x00007fd70935834d in ?? () from /snap/alacritty/x1/bin/../usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0
#10 0x00007fd709346fd9 in ?? () from /snap/alacritty/x1/bin/../usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0
#11 0x00007fd709342a94 in ?? () from /snap/alacritty/x1/bin/../usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0
#12 0x00007fd709343032 in ?? () from /snap/alacritty/x1/bin/../usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0
#13 0x000055e810669773 in glutin_glx_sys::glx::Glx::QueryExtensionsString ()
    at /root/parts/alacritty/build/target/release/build/glutin_glx_sys-e1d9a1e82b57e718/out/glx_bindings.rs:553
#14 glutin::api::glx::load_extensions () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/api/glx/mod.rs:757
#15 glutin::api::glx::Context::new () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/api/glx/mod.rs:108
#16 glutin::platform_impl::platform_impl::x11::Context::new_first_stage::{{closure}} ()
    at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/x11.rs:319
#17 glutin::platform_impl::platform_impl::x11::Context::new_first_stage () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/x11.rs:371
#18 glutin::platform_impl::platform_impl::x11::Context::new_impl () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/x11.rs:455
#19 glutin::platform_impl::platform_impl::x11::Context::new::{{closure}} () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/x11.rs:430
#20 0x000055e81067b05d in glutin::platform_impl::platform_impl::x11::Context::try_then_fallback ()
    at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/x11.rs:169
#21 glutin::platform_impl::platform_impl::x11::Context::new () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/x11.rs:429
#22 glutin::platform_impl::platform_impl::Context::new_windowed () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/platform_impl/unix/mod.rs:123
#23 glutin::windowed::<impl glutin::ContextBuilder<T>>::build_windowed () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.26.0/src/windowed.rs:341
#24 alacritty::window::create_gl_window () at alacritty/src/window.rs:133
#25 0x000055e81079381e in alacritty::display::Display::new () at alacritty/src/window.rs:186
#26 0x000055e8107a5e4b in alacritty::main () at alacritty/src/main.rs:144

I don’t think this is related to alacritty itself because I compiled it in a multipass VM and the binary works just fine. The issue seems to be related to my snap but I can’t find out why.

The latest snap code is here: https://github.com/tunix/alacritty-snap/

The user I’m initiating alacritty with throws permission errors while trying to open /dev/dri/card0. But I still get core dumped error when running the snap with sudo. :frowning:

$ alacritty -vvv
Created log file at "/tmp/Alacritty-528526.log"
[2021-01-21 01:50:02.582599194] [INFO ] [alacritty] Welcome to Alacritty
[2021-01-21 01:50:02.583587293] [INFO ] [alacritty] Configuration files loaded from:
                                                      "/home/kanata/.config/alacritty/alacritty.yml"
[2021-01-21 01:50:02.593324785] [TRACE] [crossfont] Number of fonts is 49
[2021-01-21 01:50:02.593360064] [TRACE] [crossfont] Got font path="/home/kanata/.local/share/fonts/UbuntuMono/Ubuntu Mono Nerd Font Complete.ttf", index=0
[2021-01-21 01:50:02.593415961] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Regular, load_flags: TARGET_LIGHT, render_mode: "Normal", lcd_filter: 1 }
[2021-01-21 01:50:02.594045437] [DEBUG] [alacritty] Estimated DPR: 1
[2021-01-21 01:50:02.594089391] [DEBUG] [alacritty] Estimated window size: Some(PhysicalSize { width: 1400, height: 825 })
[2021-01-21 01:50:02.594101155] [DEBUG] [alacritty] Estimated cell size: 7 x 15
libGL error: failed to open /dev/dri/card0: Permission denied
libGL error: failed to open /dev/dri/card0: Permission denied
libGL error: failed to load driver: iris
[1]    528526 segmentation fault (core dumped)  alacritty -vvv

You’re going to want the mesa part found in this: https://github.com/cjp256/alacritty/blob/531968f2dc40e9274a87fabc8082e42ed62d004a/extra/linux/snap/snapcraft.yaml#L54

The reason is that the mesa bits are broken when patchelf is run against them, likely causing your segfault. So this part stages the mesa without running patchelf.

Feel free to borrow any other bits :smiley:

2 Likes

I did some modifications and it worked. Thank you @cjp256! Adding no-patchelf to alacritty was also necessary.

1 Like

Hrm, adding no-patchelf on alacritty may have undesired side effects, such as loading libraries from your host. Consider testing your snap on an older distro (e.g. ubuntu 16.04) to verify correct functionality.

Hi @cjp256,

:frowning: Will check, thanks for the warning.

Also snapcraft-desktop-helpers are enforcing XDG folders to be relative to alacritty but this is a bit odd for a classic snap. neovim starts to search its config under those XDG folders as an example.

I created an issue on snapcraft-desktop-helpers and am currently looking for a way to change this behaviour. Maybe I’ll remove snapcraft-desktop-helpers and only apply the necessary env vars but I’m not really sure what else the helper script do.

I’ve updated snapcraft.yaml and managed to make it work without adding no-patchelf to alacritty itself. I also removed snapcraft-desktop-helpers as it tempers XDG env vars making it impossible to work with other apps (such as neovim) inside it. I only added necessary env vars and it worked.

Currently the only issue I’ve seen so far is that the background-opacity is always opague. I couldn’t find any errors or related info about this problem yet.

Added back snapcraft-desktop-helpers after adding a wrapper script to overwrite 2 XDG variables. Fixed issues:

  • Taking screenshots when in fullscreen is fixed

Current issues:

  • Cursor theme is X11’s default ones which is a bit annoying (i’d expect it to work with current cursor theme as this is classic snap)

  • Lack of transparency (as can be seen in this github issue alacritty devs claim that this leads to lack of compositor)