libwayland-cursor exits on unsuccessfull fallocate causing applications to crash
Rererenced this problem here: https://github.com/swaywm/sway/issues/4918
My setup: alpine linux (musl) + zfs on root
All Wayland applications crash with similar symptoms
strace
open("/tmp/wayland-cursor-shared-keMDcG", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0600) = 8
fcntl(8, F_SETFD, FD_CLOEXEC) = 0
unlink("/tmp/wayland-cursor-shared-keMDcG") = 0
fallocate(8, 0, 0, 1024) = -1 EOPNOTSUPP (Not supported)
close(8) = 0
write(2, "thread '", 8thread ') = 8
write(2, "main", 4main) = 4
write(2, "' panicked at '", 15' panicked at ') = 15
write(2, "Memory allocation failure while "..., 48Memory allocation failure while loading a theme.) = 48
I believe that this line causes the crash https://gitlab.freedesktop.org/wayland/wayland/blob/master/cursor/os-compatibility.c#L159
The problem is that not every filesystem supports fallocate
and glibc has a hacky fallback workaround for this, while musl does not. Musl developers argue that it is application's responsibility to handle this case and provide a fallback behavior.
ZFS does not support fallocate since it is COW FS https://github.com/zfsonlinux/zfs/issues/326
I think that this problem can easily be fixed by falling back to other branch of #ifdef HAVE_POSIX_FALLOCATE
before returning -1