[Bug]: Wayland: fall back to ftruncate when posix_fallocate is unsupported (FreeBSD/ZFS)
What happened?
Hello, I would like to report a reproducible issue in Conky's Wayland backend on FreeBSD 15.1-RELEASE with ZFS. When Conky creates the anonymous file used for a wl_shm buffer, os_create_anonymous_file() in src/output/display-wayland.cc calls: posix_fallocate(fd, 0, size) On the tested FreeBSD/ZFS system this returns EOPNOTSUPP (Operation not supported). The current implementation treats every non-zero return value as fatal, closes the descriptor, and aborts creation of the wl_shm_pool. The visible failure is: creating a buffer file for 4B failed: Operation not supported could not allocate shm pool for 1x1 window I isolated the issue and tested a minimal source change which preserves the existing error path for real allocation failures, but falls back to ftruncate(fd, size) only when posix_fallocate() reports that preallocation is unsupported (EOPNOTSUPP, ENOTSUP, or ENOSYS). The change affects only: src/output/display-wayland.cc function: os_create_anonymous_file(off_t size) I validated the patch against upstream tag v1.24.2. Validation included: reproduction of the original failure without LD_PRELOAD or any shim; clean application of the patch to a pristine v1.24.2 source tree; successful source build on FreeBSD; successful Wayland runtime without LD_PRELOAD; confirmation that no workaround shim was mapped; 12/12 runtime samples with the patched binary remaining operational; zero wl_shm creation errors during the validation window. A detailed technical report with the test environment, reproduction procedure, root-cause analysis, build parameters, linker evidence, runtime evidence, limitations, and the validated diff is attached. I also have the validated patch ready and can submit it as a focused pull request modifying only src/output/display-wayland.cc. The proposed behavior is intentionally not FreeBSD-specific: the fallback is selected by the returned error condition rather than by #ifdef FreeBSD, so other platforms or filesystems where POSIX preallocation is unsupported could benefit from the same handling. Thank you for reviewing it.
conky-wayland-freebsd-report-en-r2.pdf
406r2-conky-wayland-posix-fallocate-fallback.patch
Version
1.24.2 (FreeBSD package; conky -v reports 1.24.1)
Which OS/distro are you seeing the problem on?
Linux (other)
Conky config
conky.config = {
out_to_wayland = true,
out_to_x = false,
out_to_console = false,
background = false,
update_interval = 1.0,
total_run_times = 0,
minimum_width = 300,
minimum_height = 80,
alignment = 'top_left',
gap_x = 30,
gap_y = 30,
draw_shades = false,
draw_outline = false,
draw_borders = true,
};
conky.text = [[
SOURCE PATCH TEST
${time %Y-%m-%d %H:%M:%S}
${uptime}
]];Stack trace
Not provided. The failure is reproducible during Wayland wl_shm pool creation; full reproduction and validation evidence is attached in the technical report.Relevant log output
Source: brndnmtthws/conky